Application: Spring Boot Hello World
- GitHub — Source Code Management
- Maven — Build Tool
- Jenkins — Continuous Integration (CI/CD)
- JFrog Artifactory — Artifact Repository Manager
- SonarQube — Code Quality and Code Analysis
- Docker— Container Engine
- Tomcat — Application Server
- Tools like Jenkins, Artifactory, SonarQube Server is installed and the server is up and running
- Jenkins CI/CD — JFrog Artifactory Jenkins Integration
- Jenkins CI/CD — SonarQube Jenkins Integration
- Please make sure the following Jenkins Plugins are installed for this lab setup in the Jenkins Server ---- Pipeline, Artifactory, SonarQube Scanner for Jenkins, Email Extension Plugin.
Pre-requisites: Jenkins and Artifactory Server is installed and the server is up and running
-
Install the Artifactory Plugin in Jenkins Manage Jenkins → Manage Plugins → Click on the Available tab and search for the ‘Artifactory Plugin’ → Click on ‘Download now and install after restart
-
Go to Jenkins Home Page, Click on Manage Jenkins → Configure System → Search for the JFrog Section.
Fill the Server ID :
artifactory( It can be any logical name ) Place your JFrog Platform URL in the URL:http://jfrog.doriginlabs.com:8082UnderDefault Deployer Credentialsadd the Username and Password and click on theTest ConnectionButton. If the provided URL, username and password is correct, after clicking on the Test Connection, A message is displayed as shownFound Artifactory 7.38.7
Pre-requisites:
Jenkins and SonarQube Server is installed and the server is up and running
-
Install the SonarQube Scanner for Jenkins in Jenkins Manage Jenkins → Manage Plugins → Click on the Available tab and search for the ‘SonarQube Scanner for Jenkins’ → Click on ‘Download now and install after restart’
-
Go to SonarQube Home Page, Click on Administration → Under Security drop down click on Users
-
In the administrator user, Click on the Token Section ( marked below)
-
After clicking, a window will pop up like the below.
Enter the Token name as Jenkins-Sonar ( It can be any logical name ) and click on the Generate Button. Copy the token in the notepad and click on the done button
-
Go to Jenkins Home Page, Click on the Credentials and add the generated token from the SonarQube.
-
Go to Jenkins Home Page, Click on Manage Jenkins → Configure System → Search for the SonarQube Section.
-
Fill the Name:
sonar( It can be any logical name ) Place your sonar URL in the Server URL:http://sonarqube.doriginlabs.com:9000In Server authentication token, select the recently added secret text of the generated token from theSonarQube( Step 4 ) and click on the save button.
-
Go to Pipeline Section, Select the Git Repository and save the job GitHub URL: https://github.com/dorigintech/CI-CD-Demo.git Branch: main
-
Clicking on the build to trigger the Job.
-
Please find the Output Below.
Jenkins Console Output Log is attached for your reference:
-
To check the code is deployed correctly, Please follow the below URL Pattern:
http://jenkins.doriginlabs.com:8050/helloworld-0.0.1-SNAPSHOT/hello
-
Jenkins Pipeline Stages Screenshot:
-
In the above Screenshot Fig.1
-
Defined the maven and Artifactory methods globally in Jenkins File
-
Set the tools name of Java and Maven location as mentioned in the Jenkins — Global Tool Configuration ( Refer Screenshot Fig.2) below.
-
Included the options to have the timestamps and log rotation of the builds.
-
Set the Environment of SonarQube scanner tool name as mentioned in the Jenkins — Global Tool Configuration ( Refer Screenshot Fig.2) above.
stages { stage('Artifactory_Configuration') { steps { script { rtMaven.tool = 'Maven' rtMaven.resolver releaseRepo: 'libs-release', snapshotRepo: 'libs-snapshot', server: server buildInfo = Artifactory.newBuildInfo() rtMaven.deployer releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot', server: server buildInfo.env.capture = true } } } stage('Execute_Maven') { steps { script { rtMaven.run pom: 'pom.xml', goals: 'clean install', buildInfo: buildInfo } } } stage('SonarQube_Analysis') { steps { script { scannerHome = tool 'sonar-scanner' } withSonarQubeEnv('sonar') { sh """${scannerHome}/bin/sonar-scanner""" } } } stage('Quality_Gate') { steps { timeout(time: 1, unit: 'MINUTES') { waitForQualityGate abortPipeline: true } } } -
In the above code explains the Artifactory, SonarQube Analysis, SonarQube Quality gate Stage.
Note: “ Quality Gate” stage is written in the Jenkins File to make the Jenkins build fail if the Sonar Quality Gate metrics is not met.
-
“Deleting docker images and Containers” stage is written to make sure if any docker images and containers are running to be removed before the actual build happens.
Note: In screenshot Fig.4 the mentioned “delete_cont.sh” shell script is found below.

-
In the Screenshot above Fig.5 explains the below: Building the Docker Image Docker login to perform the pushing of the build image to the Dockerhub Running the Docker Container of tomcat to port 8050
Note: Dockerfile is found here.
-
In the above Screenshot Fig.6, changed the RUN command to startup the tomcat server with the Port 8050 ( Default port is 8080)
always { mail bcc: '', body: "<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br>URL: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "Success: Project name -> ${env.JOB_NAME}", to: "sudhan@thrivetech.in"; } failure { sh 'echo "This will run only if failed"' mail bcc: '', body: "<br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br>URL: ${env.BUILD_URL}", cc: '', charset: 'UTF-8', from: '', mimeType: 'text/html', replyTo: '', subject: "ERROR: Project name -> ${env.JOB_NAME}", to: "sudhan@thrivetech.in"; } } } -
Defines one or more additional steps that are run upon the completion of a Pipeline’s or stage’s run
-
Triggers the mail based up on the Success or Failure of the Build
Hope you have enjoyed setting up the Pipeline 😊




















