Unable to run mvn.bat on Jenkins with master/slave on Windows - java

I have a master/slave setup running on Windows 2008 RC2. The master doesn't really do anything other than being a master.
The slave I have then runs the build, which works fine for maven projects (Jenkins maven projects). If I create a free-style project I cannot run mvn.bat using a maven target. The exception is that mvn.bat cannot be resolved (path not found).
Maven is installed on the slave through the master, that is, maven was pushed onto the slave through the "install maven" feature.
Does anyone have an idea as to how I can resolve this? I'm using the interface for installing as I do not have access to the system through e.g. remote desktop. Thus I can upgrade/change the maven version for one or more projects, so a system property does not solve my problem on the long run.

As Slav wrote, using "Default" as Maven Version will find what is installed on the operating system (that is, somewhere on the system path).
The solution is to select a version and not "Default". I have installed Maven 3.0.5 using the Jenkins installed, selecting this version fixed the issue. Or you could setup the path on the system, but this requires access to the server (which I do not have, only the web interface).

Related

Cannot run Maven on Jenkins with Ubuntu

I am struggling to get a simple maven project running on Jenkins, which runs on my new Ubuntu server (16.04.)
I have installed Jenkins onto an Ubuntu, installed Maven and JDK.
I can connect to bitbucket and access my remote repository and get hold of my code. However, when I try to build I get the message
cannot run program "mvn" (in directory "/var/snap/jenkins/workspace/project") no such file or directory
I have added $JAVA_HOME and $MAVEN_HOME to my /etc/environment as variables and also into my path.
I have looked at the Global Tool Configuration, but this seems to be no help.
When I set the Maven installer to point at Maven home I get a message
/usr/share/maven is not a directory on the jenkins master
When I try to get Jenkins to install maven for me I get
Failed to install <truncated>apache-maven-3.5.3.bin.zip to /var/snap/jenkins/6/tools
...
Caused by: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must not be empty
I think I have hit a dead end. What could I be missing, or how can I get past these obstacles ?
Many Thanks
Go to Manage Jenkins -> Global Tool Configuration. I always elect to have Jenkins install and manage Maven, vs install and bring my own.
It has taken a long time to get to the bottom of this.
By default the
sudo apt-get install jenkins
seems to install a Snap version of Jenkins.
This snap version holds data in different locations (which is why I struggled to find the initialAdminpassword
Additionally, the snap setup only has a JRE, which cannot be overridden to a JDK, and therefore does not seem to work properly with Maven.
Eventually, I completely uninstalled Jenkins, and then followed the instructions on the official Jenkins site:
https://pkg.jenkins.io/debian-stable/
This overrides the base apt-get packages, and points to the jenkins.io packages.
From here on in, it all behaved as per the documentation.

Jenkins - Unable to access to repository

I am trying to configure Jenkins to download code from SVN repository and to prepare builds.
Jenkins is on one linux machine - version 1.651.1
Subversion Plug-in 2.5.7
SVN repository is set on another linux machine.
A set repository URL to eg: http://abcsvn/svn/project/branches/branch_a/HEAD/
Unfortunately I get: 'Unable to access to repository' message from Jenkins.
I also tried to put IP instead of abcsvn.
From terminal on linux machine where the Jenkins is installed I can ping IP successfully.
What may be the reason of that kind of problem? The URL is correct, because I paste that in Chrome on my machine and it worked correctly.
I also installed Jenkins on my computer with Windows. I set the same parameters and I am still not able to connect to svn repo. In Eclipse I don't have any problem to commit and checkout from svn repo.
If you need any more information to diagnose this problem I will try to complete this post.
Exception says that you have not provided credentials of your svn repository. In newer version of svn we can provide this credential while we configure workspace. In your version it can be provided from manage Jenkins menu.

Do i need to use embedded maven for m2e workspace resolution to work?

In my previous pc I was working with linux, eclipse Indigo, m2e (I suppose v1.2 or v1.3) and maven 2.
I had configured m2e to use my external maven 2 installation, had projectA depend on projectB and without the need to install any of the projects to the maven local repository I could execute an Eclipse Maven Build (e.g: compile or dependency:tree) configured to use the external maven installation and to Resolve artifacts in workspace. That worked.
Now, I 'm using win7, eclipse kepler, m2e 1.4.1 and maven 3. I configured all in the same fashion (use external maven installation), create the same projects, use the same eclipse Maven build (run configuration) with workspace artifact resolution enabled and it don't work.
Right now it only works if i configure the maven build to use the internal eclipse embedded maven installation.
I 'd really like to always use my external instalation, does anyone knows if this feature was removed from m2e or should this scenario work as I expected and maybe it's a bug thats happening in my specific environment?
It's worth checking that the settings.xml for your external maven makes sense, and eclipse is configured to use it.
I 've tested in other similar environments obtaining same results but, when
upgraded to Eclipse Luna problem was solved.
If you 're facing similar problem, then upgrade to Eclipse Luna.

Jenkins Maven Build Not Picking Up Java Home

The version of Jenkins I am using seems to not be correctly picking up the value for Java Home that I am setting as a Global Variable
if I run a clean install on my pom as a Pre Build Step - it picks up the Java Home variable that I set
If I run a clean install on my pom as a Build step - it picks up another version of Java on my linux box thats not set as Java Home
I have tried a few things including deleting the version of Java that the Build Step is picking up but to no avail. For now I will execute my build as a Pre Build step until I have figured out the problem
The version of jenkins I am using is Jenkins ver. 1.565.3
Have you configured the JDK installation under Manage Jenkins Global Configuration?
Have you configured your maven job to use that particular JDK? (If you have just one, it will always use that one)
Jenkins will install and maintain it's own JDK, independent of what you have pre-installed on the operating system

Managing Maven project in Eclipse with git repository

we recently migrated to Maven Build manager & git hub repository for our Java web-app. Also i switched to eclipse as eclipse has good set of plugins.
As a new bie, i am simply running mvn clean package from terminal at the code root directory. And then moving the compiled code i.e., /target/SNAPSHOT/* to tomcat/webapps/ROOT location.
And then starting Tomcat7 server. The process is time taking especially when i do code changes in Java & configuration .xml files.
I want to do it completely in IDE environment as i did earlier in Netbeans, update code -> build and run in debug mode, -> do code changes and then commit.
Heard of egit & m2e in eclipse for maven & github integration, but not sure how to use it.
Please walk me through the steps required in doing so. I am completely new to eclipse.
--
Thanks
You might want to consider using maven-jetty-plugin http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin for running the webapp. You will not need to copy over stuff to tomcat. After configuring this plugin, you can simply run your application by doing mvn jetty:run
I generally do not like running webapps inside Eclipse. It's a personal prefrence, but it is always nice to have an IDE neutral way of building and running your applications. If you have m2e things should work simply fine. I have seen maven-jetty-plugin having hot pluggability where if you changed your web.xml, jetty would reload your application.
We use Git for version control and Maven for dependency management and build automation. Once your project has successfully imported into Eclipse and recognized as a valid java web project, you don't need either Git or Maven in order to build/run it inside IDE. Just creat a server using you existing tomcat installation, add the project to server, then select Run as > Run on Server.
The Complete Guide:
Creating a server
Adding projects to a server
Starting a server
For more details, check out Testing and publishing on your server.

Categories

Resources