Reputation: 431
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.
Upvotes: 2
Views: 14457
Reputation: 2018
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.
Upvotes: 2