On each maven build or release, how to get new jar version in Jenkins. I have tried it in Jenkins but only getting same jar file name as it is in pom file.
you can use maven-exec-plugin to print the version to stdout or write it in a file:
mvn -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:exec
Related
I have jenkins installed on a remote machine. How can I point my POM location in Jenkins. If I give the POM.xml location as C:\Automation\pom.xml I am getting the error no such file exists.
Started by user anonymous
Building in workspace C:\Users\Administrator\.jenkins\workspace\RegressionTestJob
Parsing POMs
ERROR: No such file C:\Automation\pom.xml
Perhaps you need to specify the correct POM file path in the project configuration?
TestNG Reports Processing: START
Looking for TestNG results report in workspace using pattern: **/testng-results.xml
Did not find any matching files.
Finished: FAILURE
Your pom should be in your workspace, like how you would build your project in an IDE e.g. eclipse and when you build your project Jenkins will find the pom on its own in the workspace and build the project
Incase you still wish to specify the location you can use the -f option
mvn -f PomFile.xml
Hope it helps :)
I have a maven project (assume it is just a simple hello-world java program) in git. Now I want to (1) create the jar file; (2) run this jar file. How can I do this through Jenkins Job Builder hourly (like every one hour Jenkins will build the jar file, and execute it)? Thanks.
First of all, create a Jenkins Freestyle Project.
TZ=Asia/Kolkata
0 */1 * * *
Please add the above code in Build periodically box. It will run your code once an hour. For creating the jar file,
cd '<your project location in the disk>'
mvn clean install
Now this will build your jar file. To run the jar file,
cd 'target'
java -jar <project jar file name>.jar
So total script will be like :
cd '<your project location in the disk>'
mvn clean install
cd 'target'
java -jar <project jar file name>.jar
Add the above code to Execute shell block in Build -> Add build step -> Execute shell in the job configuration. Hope this is what you are looking for.
I do have a jenkins job that builds XML beans jar files from the internal gitlab project and puts it on the artifactory. While having a build, this XML beans jar files are downloaded to the .m2 maven local repository. However, if this jar file exists in the .m2 repository then maven does not bother to download it from the artifactory. With being said, if there is a gitlab change, it does build it and put it on the artifactory. As there is already a jar file exist in .m2 repository, an old jar file is not being replaced with the new one. We ended up a wrong dependency to the customer with a release.
The question is , What am I doing wrong here?
mvn clean install -U
-U means maven will force update snapshot dependencies. Release dependencies can't not be updated this way.
We're trying to use the Artifactory release process in Jenkins to publish a jar file created by a Gradle build into a Maven repo in our Artifactory server.
It nearly all works, the only issue is that the pom file isn't being copied into the Artifactory repo.
The Gradle build includes the Gradle Maven plugin and running gradlew install locally results in both the jar and the pom inserted into the local Maven repo.
I've added a task in the Gradle build that generates the pom file in the same directory as the jar file and changed the Jenkins build to run that task too.
When the build has completed I can see both the jar and the pom file in the workspace.
Any ideas on what I need to do to get the pom file published along with the jar?
We're using:
Jenkins 2.10
Artifactory plugin 2.4.4
Gradle 2.14
The Gradle build file does not inlcude the Gradle Artifactory plugin.
Cheers, Andy
The Jenkins project is configured to use the Gradle-Artifactory integration (rather than the Generic-Artifactory integration).
As suggested by Dakota Brown I'm answering my own question, the solution to my problem was to un-tick the maven3 integration option. With that option unslected, everything works as expected.
I've installed two libraries to my local repository (JGraph and JGraphtT). I used this command:
mvn install:install-file -DgroupId=org.jgrapht -DartifactId=jgrapht -Dversion=0.8.3 -Dpackaging=jar -Dfile=./jgrapht.jar
and similar for JGraph. I can see that the two Jar files are in my local repository.
When I try to create Eclipse classpath and build files from the directory of my project's POM file (using mvn eclipse:eclipse), I get this error:
[WARNING] Missing POM for org.jrapht:jgrapht:jar:0.8.3
and similar for JGraph.
Any ideas on what I'm doing wrong? My settings.xml file has the local repository enabled.
Thanks,
Keith