How to deploy my Spring Boot project on Jenkins?

I am trying to create a deploy job in Jenkins for my Spring Boot - Maven project. These are the steps i have followed until now:

  • Click New Item
  • Give a name, and choose Maven project
  • Configuration page opens
  • In Source Code Management, i have given my Git repository URL
  • In Build section under Goals and options i have written "spring-boot:run"
  • Saved and applied

Now when i click "Build Now", it checks out the project, builds and deploys. But the job does not end. This is the last line in the console output screen:

: Started Application in 4.737 seconds (JVM running for 16.297)

What is my problem? I need a simple step by step guidance since i do not have any Jenkins experience.

EDIT: I do not know what post build action is which is mentioned in the other post. I need a simple step by step guidance since i do not have any Jenkins experience.

Answers


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.


Need Your Help

Git - How to fix "corrupted" interactive rebase?

git msysgit git-rebase

I managed to create a little mess in my local git repository. I was trying to fix a broken commit by using the following instructions. Before running the "git commit --amend" (and after the git reb...

Python app engine put(self):

python google-app-engine

I am using this middleware to make my app restful, but it looks like my form parameters are not coming through: