How to run a jar file generated by maven in Jenkins Job Builder
11,882
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.
Related videos on Youtube
Author by
batilei
Updated on June 04, 2022Comments
-
batilei almost 2 years
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.
-
Night Programmer about 6 yearsmeans you want executable jar file, Can you explain more?
-
batilei about 6 yearsHello Sandip, generally yes, want a jar and execute in Jenkins job. Answer given by Madhava below basically solves my problem. Thanks
-