Jenkins For Building SpringBoot#
Jenkins Configurations#
- Now, firstly when the Jenkins is started, you should goes to
Manage Jenkins-->Manage Nodes And Cloudsas the image below:
- Then you can see, by default
Jenkinswill have an built-in node which is your real machine that you are using to runJenkinsbydocker. - Then you need to go
Manage Jenkins->Global Tool Configurationas the image below
- Then you scroll down to find the tag
Maven. You should put aNamethen chooseInstall automaticallyand then choose theVersionof Maven that you want to install.
- Next you scroll to tag
JDKand put a name for it likeJDK8. We don't need to install JDK 8 anymore because we already have JDK 8 by default inside the docker imagejenkins.
- Finally, you scroll to tag
Gitand put aName-> setPath to Git executableas/usr/bin/git-> chooseInstall automatically. Click buttonSave.
Create Pipeline On Jenkins#
- Now, we will try to create a pipeline on Jenkins for building SpringBoot project. Firstly, you go to
Dashboardand clickNew Item. - Then you set a
Name-> chooseMultibranch Pipeline-> clickOk.
- Next, in tag
Branch Sources, you put some information about yourGitHub RepositoryandBranchthat you want Jenkins clones and builds. - Note: you can set multi
branchesfor Jenkins Build.
- Next, You scroll down and config
Build ConfigurationandScan Multibranch Pipeline Triggersas the image below. - Note that
Script Pathis thepathtoJenkinsfilein your GitHub repository(your source code on GitHub). - For
Scan Multibranch Pipeline TriggerschoosePeriodically if not otherwise runandIntervalas1 minute.Intervalmeans when your repository has changed so the pipeline will be triggered automatically after 1 minute. - Finally click
Save
Create Jenkins File In Your Repository#
- So let craete a folder in the root of your repository name
jenkinsand a file namebuild.Jenkinsfileas you defined in theJenkins Pipeline.
- In the file
build.Jenkinsfile. Let’s add scripts as below
| build.Jenkinsfile | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
- Now, let’s commit and push your code changes to your respository and check the Jenkins Pipeline, You can see It’s built successfully.
- So, That’s it. Thanks and Good luck!











