How to deploy my Spring Boot project on Jenkins? How to deploy my Spring Boot project on Jenkins? jenkins jenkins

How to deploy my Spring Boot project on Jenkins?


The job doesn't end because your application is up and running on embeeded Tomcat. It's normal behaviour and you should be able to use your application at this point.


If you want to make another build, you should stop current build before starting a new one. To do this automaticaly (e.g. when your master branch is changed) you can create another one job.

Example of a job that triggers build of a main job:

  • Create a 'Freestyle project' in Jenkins;
  • Fill 'Source Code Management': your Repository URL and Credentials, Branches to build - */master;
  • Fill 'Build Triggers': select 'Poll SCM' and type H/2 * * * * in 'Shedule' to poll repository every 2 minutes;
  • Fill 'Build': add build step 'Execute shell' and type next commands to stop current build and start a new one (don't forget to replace JENKINS_URL and JOB_NAME with your values) -

    curl -X POST http://JENKINS_URL/job/JOB_NAME/lastBuild/stop;curl -X POST http://JENKINS_URL/job/JOB_NAME/build;
  • Save your job :)


I think that if you are going to deploy the spring-boot application in another server different to jenkins server you need to build your app mvn clean package and to move the jar created from jenkins server to the new server then you can use another step to start the app using java -jar myapp.jar. But, if you are going to deploy in tomcat server then you can use tomcat-api to deploy remotely.