-
Couldn't load subscription status.
- Fork 0
Jenkins Configuration
- Jenkins is an opensource tools based on java application used for CI/CD.
- We will run jenkins in a docker container so docker must be installed and ready in your machine.
- We also require docker inside jenkins to build docker images. But the official jenkins docker image do not include docker inside it so we will be using our own custom jenkins image.
- The custom jenkins image can be found in DockerHub. Visit this link to download the image.
- Read the description in the DockerHub to know more about the images.
- Since docker is also require in jenkins container, we need to mount the docker socket from our machine to the jenkins container.
- The command to run the jenkins container:
docker run -d --name jenkins -p 8080:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v jenkins_home:/var/jenkins_home thespiritman/jenkins-with-docker:latest - Output:
- The flag
--namewill create conatiner namedjenkins. - The flag
-dwill run the container in a detached mode (simply background). - The flag
-pwill forward the container port to the host port. The format is <host_port>:<container_port>. This means port 8080 and 50000 are forwarded to host machine. - The flag
-vis used to the mount the volume. Here,/var/run/docker.sockis mounted so docker can be accessed from teh container. Also a new volume namedjenkins_homeis mounted to the path/var/jenkins_home. This volume included necessary backups. -
thespiritman/jenkins-with-docker:latestis a docker image name which can be found in DockerHub.
-
Visit http://<your_ip>:8080 to access jenkins. Do not use localhost, problem will occur while configuring with Sonarqube.
-
Since my private ip address is 192.168.18.8. So I can visit http://192.168.18.8:8080.
-
It asks for a admin password. Also it shows the path where you can we find the password i.e
/var/jenkins_home/secrets/initialAdminPassword.
-
Command to get passwd:
docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword
-
Copy the password and paste in the jenkins webpage.
-
It then shows the plugin menu. Select to install the suggested plugin.

-
It will take time to install the plugin based on your internet speed.
-
Once it finishes installing all the plugin, it asks to create admin user.You can also skip and uses admin user with the initial password.
-
I will create a new admin user with username admin and password admin.
-
Save the crendential and move forward.
-
Live default for Instance Configuration and Click in
Save and Finish. -
Start using jenkins.
-
Default jenkins homepage will looks like below:

-
Since we are building the maven project. So we must install maven for that.
-
GoTo Manage Jenkins, then Global Tool Configuration. Scroll down to Maven Installations, then add the maven installation, set the maven name as
MAVEN_HOMEas this name is referred in Jenkinsfile and save the changes.
-
So this maven tool will be installed only once when our jenkins pipeline will be triggerred for the first time.
- Jenkins is now ready to serve the first 3 stages of the Jenkinsfile.
- You can use below code to test the working till now.
pipeline { agent any tools { maven 'MAVEN_HOME' } stages { //stage 0 stage('Git pull'){ steps{ git branch: 'main', url: 'https://github.com/TheSpiritMan/demo-counter-app' } } //stage 1 stage('Unit Testing') { steps{ sh 'mvn test' } } //stage 2 stage('Integration Testing'){ steps{ sh 'mvn verify -DskipUnitTests' } } //stage 3 stage('Maven Building'){ steps{ sh 'mvn clean install' } } } }
For now jenkin's work is done. Now go to Sonarqube configuration Page. Remember we still have so many to configure in jenkins.
-
To work with sonarqube, we have to install some Sonarqube plugins.
-
GoTo Manage Jenkins, then Manage Plugin and select the Available Plugins. Now search for
sonar quality.
-
Now click on Install without Restart. It will take some times to install the selected plugin.
-
Once all the required plugins are installed, we can move forward.
-
GoTo Manage Jenkins, then Manage Credentials. Select System, and click on Add Credentials.
-
From Drop-Down Menu, select Secret text Kind. Paste the token generated in Sonarqube to Secret and enter
sonarqube-keyin ID and Description. Then click on Create.
-
We can see that our credential is listed in the Global credentials table.
-
GoTo Manage Jenkins, then Configure System. Scroll down to SonarQube Servers. We can see something like below:

-
Now, check the tick mark for the Environment Variables. Click on Add SonarQube. Fill the details for the sonarqube as below and save the changes.

-
GoTo Manage Jenkins, then Global Tool Configuration. Scroll down to SonarQube Scanner. Click on Add SonarQube Scanner. Name it as sonar. This is used in the Jenkinsfile.
- Jenkins is now ready to serve the first 4 stages of the Jenkinsfile.
- You can use below code to test the working till now:
pipeline { agent any tools { maven 'MAVEN_HOME' } stages { //stage 0 stage('Git pull'){ steps{ git branch: 'main', url: 'https://github.com/TheSpiritMan/demo-counter-app' } } //stage 1 stage('Unit Testing') { steps{ sh 'mvn test' } } //stage 2 stage('Integration Testing'){ steps{ sh 'mvn verify -DskipUnitTests' } } //stage 3 stage('Maven Building'){ steps{ sh 'mvn clean install' } } //stage 4 stage('SonarQube Analysis'){ steps{ withSonarQubeEnv(credentialsId: 'sonarqube-key', installationName: 'sonarqube-server') { sh 'mvn clean package sonar:sonar' } } } } }
- To receive report back from Sonarqube, we must create a webhook in a Sonarqube.
- Go to Jenkins Webhook Configuration in Sonarqube Configuration Page.
- Once webhook is created, then the jenkins job is ready to be serve upto Stage 5.
- The Stage 5 requires sonarqube credential which is already stored in jenkins Credentails.
-
Jenkins is ready to serve the first 5 stages of the Jenkinsfile.
-
You can use below code to test the working till now:
pipeline { agent any tools { maven 'MAVEN_HOME' } stages { //stage 0 stage('Git pull'){ steps{ git branch: 'main', url: 'https://github.com/TheSpiritMan/demo-counter-app' } } //stage 1 stage('Unit Testing') { steps{ sh 'mvn test' } } //stage 2 stage('Integration Testing'){ steps{ sh 'mvn verify -DskipUnitTests' } } //stage 3 stage('Maven Building'){ steps{ sh 'mvn clean install' } } //stage 4 stage('SonarQube Analysis'){ steps{ withSonarQubeEnv(credentialsId: 'sonarqube-key', installationName: 'sonarqube-server') { sh 'mvn clean package sonar:sonar' } } } //stage 5 stage('Quality Gate Status'){ steps{ waitForQualityGate abortPipeline: false, credentialsId: 'sonarqube-key' } } } } -
If everything goes well, then Sonarqube Quality gate must be displayed as below:
-
Also Sonarqube Webhook triggerred must return success. This can be found in Sonarqube Configuration.
For now jenkin's work is done. Now go to Nexus Configuration Page.
-
To work with nexus, we have to set credential in Jenkins.
-
GoTo Manage Jenkins, then Manage Credentials. Select System, and click on Add Credentials.
-
From Drop-Down Menu, select Username with password. Enter username and password of Nexus Repository and enter
nexus-credsin ID and Description also tick to Treat username as secret. Then click on Create.
-
To upload artifacts in Nexus, we need to install the plugin.
-
GoTo Manage Jenkins, Manage Plugins and click on Available Plugins. Search for Nexus Artifact Uploader and click on Install without restart.

-
Now, jenkins is ready to upload artifact into your nexus repository.
-
Code snippet to upload artifact into Nexus Repository can be seen below:
//stage 6 stage('Upload jar file to Nexus'){ steps{ script{ nexusArtifactUploader artifacts: [ [ artifactId: 'springboot', classifier: '', file: 'target/counterApp.jar', type: 'jar' ] ], credentialsId: 'nexus-creds', groupId: 'com.example', nexusUrl: '192.168.18.8:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'demo-counter-app-release', version: '1.0.0' } } } -
If you add above code as stage 6 then, the artifact can be uploaded successfully in demo-counter-app-release.
-
Above script can be created using Jenkins Pipeline Syntax. Break down of above stage 6 code:
-
nexusArtifactUploader artifacts: it uploads artifact to the nexus repo -
artifactId: it is taken from pom.xml of the application -
classfier: it is left empty -
file: it is the actual file/artifact to upload -
type: it denotes file type like jar/war -
credentialsId: it is credential for nexus which bis stored in Jenkins -
groupId: it is taken from pom.xml of an application -
nexusUrl: it is URL of the Nexus Repository -
nexusVersion: it indicate the nexus version being used -
protocol: it defines protocol being used like http/https -
repository: name of the repository to store artifacts -
version: version of an application,it is frompom.xml
-
-
Jenkins is ready to serve upto stage 6 but in a condition:
-
Used below pipeline code to test Nexus Artifact Uploader:
pipeline { agent any tools { maven 'MAVEN_HOME' } stages { //stage 0 stage('Git pull'){ steps{ git branch: 'main', url: 'https://github.com/TheSpiritMan/demo-counter-app' } } // stage 1 stage('Unit Testing') { steps{ sh 'mvn test' } } // stage 2 stage('Integration Testing'){ steps{ sh 'mvn verify -DskipUnitTests' } } // stage 3 stage('Maven Building'){ steps{ sh 'mvn clean install' } } // stage 4 stage('SonarQube Analysis'){ steps{ withSonarQubeEnv(credentialsId: 'sonarqube-key', installationName: 'sonarqube-server') { sh 'mvn clean package sonar:sonar' } } } // stage 5 stage('Quality Gate Status'){ steps{ waitForQualityGate abortPipeline: false, credentialsId: 'sonarqube-key' } } // stage 6 stage('Upload jar file to Nexus'){ steps{ script{ nexusArtifactUploader artifacts: [ [ artifactId: 'springboot', classifier: '', file: 'target/counterApp.jar', type: 'jar' ] ], credentialsId: 'nexus-creds', groupId: 'com.example', nexusUrl: '192.168.18.8:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'demo-counter-app-release', version: '1.0.0' } } } } } -
If everything goes well, we can see that the Soanrqube Quality Gate result had came back.
-
Also our artifact must be uploaded to Nexus Repository. For that:
-
GoTo Nexus Dashboard, select demo-counter-app-release repository. We can artifact as below:
-
-
In above stage 6 of a pipeline, we have to manually set version which does not match with the concept of Continuous Integration/Continuous Deployment.
-
We use plugin which will take values from a file and used the value in Jenkins Pipeline.
-
GoTo Manage Jenkins, then Manage Plugin and select the Available Plugins.Now search for
Pipeline utility steps.
-
Now click on Install without Restart. It will take some times to install the selected plugin.
-
Code snippet to upload artifact into Nexus Repository can be seen below:
//stage 6 stage('Upload jar file to Nexus'){ steps{ script{ def readPom = readMavenPom file: 'pom.xml' nexusArtifactUploader artifacts: [ [ artifactId: 'springboot', classifier: '', file: 'target/counterApp.jar', type: 'jar' ] ], credentialsId: 'nexus-creds', groupId: 'com.example', nexusUrl: '192.168.18.8:8081', nexusVersion: 'nexus3', protocol: 'http', repository: 'demo-counter-app-release', version: "${readPom.version}" } } } -
Since we have 2 repositories to store artifact. One for Release and another for Snapshot, so let's define a condition to check for a Shapshot.
-
Code snippet:
def readPom = readMavenPom file: 'pom.xml' def nexusRepo = readPom.version.endsWith("SNAPSHOT") ? "demo-counter-app-snapshot" : "demo-counter-app-release" -
The above code will read version from
pom.xml, if it ends withSNAPSHOT, it will assigndemo-counter-app-snapshotvalue to variable nexusRepo or elsedemo-counter-app-releaseto nexusRepo. -
The actual stage 6 will look like below:
// stage 6 stage('Upload jar file to Nexus'){ steps{ script{ def readPom = readMavenPom file: 'pom.xml' def nexusRepo = readPom.version.endsWith("SNAPSHOT") ? "demo-counter-app-snapshot" : "demo-counter-app-release" nexusArtifactUploader artifacts: [ [ artifactId: 'springboot', classifier: '', file: 'target/counterApp.jar', type: 'jar' ] ], credentialsId: 'nexus-creds', groupId: 'com.example', nexusUrl: '192.168.18.8:8081', nexusVersion: 'nexus3', protocol: 'http', repository: nexusRepo, version: "${readPom.version}" } } }
- Jenkins is ready to serve upto stage 6.
- Full code snippet upto stage 6:
pipeline { agent any tools { maven 'MAVEN_HOME' } stages { //stage 0 stage('Git pull'){ steps{ git branch: 'main', url: 'https://github.com/TheSpiritMan/demo-counter-app' } } // stage 1 stage('Unit Testing') { steps{ sh 'mvn test' } } // stage 2 stage('Integration Testing'){ steps{ sh 'mvn verify -DskipUnitTests' } } // stage 3 stage('Maven Building'){ steps{ sh 'mvn clean install' } } // stage 4 stage('SonarQube Analysis'){ steps{ withSonarQubeEnv(credentialsId: 'sonarqube-key', installationName: 'sonarqube-server') { sh 'mvn clean package sonar:sonar' } } } // stage 5 stage('Quality Gate Status'){ steps{ waitForQualityGate abortPipeline: false, credentialsId: 'sonarqube-key' } } // stage 6 stage('Upload jar file to Nexus'){ steps{ script{ def readPom = readMavenPom file: 'pom.xml' def nexusRepo = readPom.version.endsWith("SNAPSHOT") ? "demo-counter-app-snapshot" : "demo-counter-app-release" nexusArtifactUploader artifacts: [ [ artifactId: 'springboot', classifier: '', file: 'target/counterApp.jar', type: 'jar' ] ], credentialsId: 'nexus-creds', groupId: 'com.example', nexusUrl: '192.168.18.8:8081', nexusVersion: 'nexus3', protocol: 'http', repository: nexusRepo, version: "${readPom.version}" } } } } }
-
Upgrade version
1.0.0to2.0.0. Push the change to the github. Build the job in Jenkins. -
We have not given any permission to
Pipeline Utility Stepsplugin to read file, so it may ask for permission in the first build of using that plugin. Build will fail saying following errors inbuild console.
-
Click on that hyper link, you will be asked to approve or deny permission.

-
Click on
Approvebutton.
-
Now build the jenkins job, now it will get
Success. -
Output:
-
The build will be success and we can see that our artifact of verion
2.0.0is uploaded in Nexus Release Repository.
-
- Upgrade version
2.0.0to2.0.0-SNAPSHOT. Push the change to the github. Build the job in Jenkins. - Now build the jenkins job, now it will get
Success. -
Output:
-
The build will be success and we can see that our artifact of verion
2.0.0-SNAPSHOTis uploaded in Nexus Snapshot Repository.
-
- To build docker image inside jenkins server, docker must be installed in jenkins system. So to accomplish this feature, we have our own custom jenkins image which can be found in DockerHub in this link.
- Dockerfile is available in root directory of the github project.
- So docker image will be build using that Dockerfile.
- Stage 7 will build the docker image from Dockerfile.
- Code Snippet:
// stage 7 stage('Docker Image Build'){ steps{ sh 'docker build -t $JOB_NAME:v1.$BUILD_ID .' } }
- We are hosting our private docker registry in nexus, so we have prefix the image with our Registry URL. i.e 192.168.18.8:8082 for my case.
- stage 8 will tag image with prefix of Registry and also with BUILD_ID and latest.
- Remember, BUILD_ID is variable from Jenkins itself which defines the curreent build number of the jenkins job.
- Code Snippet:
// stage 8 stage('Tag Image with Nexus Repository'){ steps{ script{ sh 'docker image tag $JOB_NAME:v1.$BUILD_ID 192.168.18.8:8082/$JOB_NAME:v1.$BUILD_ID' sh 'docker image tag $JOB_NAME:v1.$BUILD_ID 192.168.18.8:8082/$JOB_NAME:latest' } } }
-
Jenkins is ready to serve upto stage 8.
-
Upgrade vesion from
2.0.0-SNAPSHOTto3.0.0inpom.xmlof the project and push to the github repo. -
Below is complete pipeline code upto stage 8:
pipeline { agent any tools { maven 'MAVEN_HOME' } stages { //stage 0 stage('Git pull'){ steps{ git branch: 'main', url: 'https://github.com/TheSpiritMan/demo-counter-app' } } // stage 1 stage('Unit Testing') { steps{ sh 'mvn test' } } // stage 2 stage('Integration Testing'){ steps{ sh 'mvn verify -DskipUnitTests' } } // stage 3 stage('Maven Building'){ steps{ sh 'mvn clean install' } } // stage 4 stage('SonarQube Analysis'){ steps{ withSonarQubeEnv(credentialsId: 'sonarqube-key', installationName: 'sonarqube-server') { sh 'mvn clean package sonar:sonar' } } } // stage 5 stage('Quality Gate Status'){ steps{ waitForQualityGate abortPipeline: false, credentialsId: 'sonarqube-key' } } // stage 6 stage('Upload jar file to Nexus'){ steps{ script{ def readPom = readMavenPom file: 'pom.xml' def nexusRepo = readPom.version.endsWith("SNAPSHOT") ? "demo-counter-app-snapshot" : "demo-counter-app-release" nexusArtifactUploader artifacts: [ [ artifactId: 'springboot', classifier: '', file: 'target/counterApp.jar', type: 'jar' ] ], credentialsId: 'nexus-creds', groupId: 'com.example', nexusUrl: '192.168.18.8:8081', nexusVersion: 'nexus3', protocol: 'http', repository: nexusRepo, version: "${readPom.version}" } } } // stage 7 stage('Docker Image Build'){ steps{ sh 'docker build -t $JOB_NAME:v1.$BUILD_ID .' } } // stage 8 stage('Tag Image with Nexus Repository'){ steps{ script{ sh 'docker image tag $JOB_NAME:v1.$BUILD_ID 192.168.18.8:8082/$JOB_NAME:v1.$BUILD_ID' sh 'docker image tag $JOB_NAME:v1.$BUILD_ID 192.168.18.8:8082/$JOB_NAME:latest' } } } } } -
If the build is success, then we should docker images inside our jenkins container.
-
Command:
docker exec -it jenkins docker bash docker images | grep demo-counter-app
-
To upload our image in in-secure registry, we have to allow it.
-
Enter below command inside jenkins container:
docker info | tail
-
We can see that we nothing in our insecure registry. Now let's add our nexus private docker repository.
-
Goto your host machine and enter following command:
-
Command:
cat << EOF > /tmp/daemon.json { "insecure-registries": [ "192.168.18.8:8082" ] } EOF sudo mv /tmp/daemon.json /etc/docker/ -
Now restart docker service in your host machine.
-
Command:
sudo service docker restart -
We have to start all the containers manually. Command:
docker start jenkins sonarqube nexus -
Now, goto inside jenkins container and enter check for insecure registry.
-
Command:
docker info | tail
-
In above figure, we can see our nexus repository in the insecure registry.
- We have to login to Nexus Repository to push image.
- We need username and password to login.
- We have already setup nexus credential in our Jenkins.
- Use password as a environment variable.
- Command:
environment { // DPR = Docker Private Repo DPR_CRED = credentials('nexus-creds') } - Code Snippet:
pipeline{ agent any tools { ....... } environment { // DPR = Docker Private Repo DPR_CRED = credentials('nexus-creds') } stages { //stage 1 .................... ................ ..................... //stage 9 stage('Push Docker Image To Private Nexus Repository'){ steps{ script{ sh 'docker login -u ${DPR_CRED_USR} -p ${DPR_CRED_PSW} 192.168.18.8:8082' sh 'docker image push thespiritman/$JOB_NAME:v1.$BUILD_ID' sh 'docker image push thespiritman/$JOB_NAME:latest' } } } } }
-
Jenkins is noew ready to server upto stage 9.
-
Complete code:
pipeline { agent any tools { maven 'MAVEN_HOME' } environment { // DPR = Docker Private Repo DPR_CRED = credentials('nexus-creds') } stages { //stage 0 stage('Git pull'){ steps{ git branch: 'main', url: 'https://github.com/TheSpiritMan/demo-counter-app' } } // stage 1 stage('Unit Testing') { steps{ sh 'mvn test' } } // stage 2 stage('Integration Testing'){ steps{ sh 'mvn verify -DskipUnitTests' } } // stage 3 stage('Maven Building'){ steps{ sh 'mvn clean install' } } // stage 4 stage('SonarQube Analysis'){ steps{ withSonarQubeEnv(credentialsId: 'sonarqube-key', installationName: 'sonarqube-server') { sh 'mvn clean package sonar:sonar' } } } // stage 5 stage('Quality Gate Status'){ steps{ waitForQualityGate abortPipeline: false, credentialsId: 'sonarqube-key' } } // stage 6 stage('Upload jar file to Nexus'){ steps{ script{ def readPom = readMavenPom file: 'pom.xml' def nexusRepo = readPom.version.endsWith("SNAPSHOT") ? "demo-counter-app-snapshot" : "demo-counter-app-release" nexusArtifactUploader artifacts: [ [ artifactId: 'springboot', classifier: '', file: 'target/counterApp.jar', type: 'jar' ] ], credentialsId: 'nexus-creds', groupId: 'com.example', nexusUrl: '192.168.18.8:8081', nexusVersion: 'nexus3', protocol: 'http', repository: nexusRepo, version: "${readPom.version}" } } } // stage 7 stage('Docker Image Build'){ steps{ sh 'docker build -t $JOB_NAME:v1.$BUILD_ID .' } } // stage 8 stage('Tag Image with Nexus Repository'){ steps{ script{ sh 'docker image tag $JOB_NAME:v1.$BUILD_ID 192.168.18.8:8082/$JOB_NAME:v1.$BUILD_ID' sh 'docker image tag $JOB_NAME:v1.$BUILD_ID 192.168.18.8:8082/$JOB_NAME:latest' } } } //stage 9 stage('Push Docker Image To Private Nexus Repository'){ steps{ script{ sh 'docker login -u ${DPR_CRED_USR} -p ${DPR_CRED_PSW} 192.168.18.8:8082' sh 'docker image push 192.168.18.8:8082/$JOB_NAME:v1.$BUILD_ID' sh 'docker image push 192.168.18.8:8082/$JOB_NAME:latest' } } } } } -
Upgrade version from
3.0.0to4.0.0inpom.xmland push to github. -
Then, build the jenkins' job.
-
Once the build is successfully completely, we can see that our image of tag
latestandBUILD_IDARE pushed into Nexus Docker Repository.
-
Stage 10 will delete all the image that matched with the name
demo-counter-app.
- Stage 11 will run our application as a docker counter and port 8888 will be forwarded to our host system, then we can access our application in our browser.
- If you want, you can delete all the artifact including docker images from Nexus Repository and also a project from Sonarqube.
- I have deleted all the previous build and all the artifact to visualize complete Pipeline in 1 go.
-
Create a new job:
-
Click on highlighed:

-
Get project name
demo-couner-appand selectPipelineand clickOkbutton.
-
Goto Pipeline section and select Pipeline script from SCM. Select Git from SCM. Enter the link of Project from Github. Change branch name from master to main and save the changes.

-
Now change version to
1.0.0inpom.xmland push to github. -
Now, click on Build Now to start.
-
Once build is successfull, we can see the project is created in Sonarqube dashboard also result has been taken from Soanrqube to Jenkins job dashboard.

-
Project artifact is also stored in Nexus Repository.
-
Docker Image is also build and pushed to Nexus Docker Registry.
-
All the docker image of the
demo-counter-appare removed to clean up spaces. -
The application is started as a docker container, which image is pulled from the Nexus Private Registry.
-
Visit http:<your_ip>:8888, in my case,it is http://192.168.18.8:8888:
-
If we refreshed page, we can see that the value is increased per refreshed.
-
-
We are doing everything on local machine with private IP. To connect Github with Jenkins Job, we need jenkins accessible from Github using Pubilc IP. We will use ngrok to forward oue Jenkins port to public address.
-
GoTo Ngrok website, create account for free and login to the system.
-
Download Ngrok for your Operating System.

-
Unzip ngrok and add auth token into your system.
-
Once completed, forward Port 8080 with ngrok.
-
Input your Jenkins IP in following command:
./ngrok http http://192.168.18.8:8080 -
Output will be similar as below:
-
The red mark in above figure is the public IP we will use in Github Webhook Setting.
-
-
Fork This Repository into your github account.
-
GoTo Settingof the forked Repository.
-
Select Webhooks and click on Add Webhooks. Fill form as below:
-
Copy and paste the Public URL from ngrok in above field. Also append
/github-webhook/in that link as above figure. -
Select
application/jsonas Content Type and click on Add webhook. -
Refresh that page and ping will be success if everything goes right.
-
Now go back to Jenkins webpage, select previous job named as
demo-counter-app. -
Click on Configure button.
-
Goto Build Triggers section, check mark on GitHub hook trigger for GITScm polling.
-
Save the changes.
-
Upgrade version from
1.0.0to1.5.0-SNAPSHOTinpom.xml. -
Remove counterApp container, so the build doesnot give error saying
container with named <b>counterApp</b is already present. Commad:docker rm counterApp --force -
Push the changes to github and our jenkins build must be triggered automatically from Github Webhook.
-
Then our jenkins job will build automatically as below:
-
Once build is success, we can see that our SNAPSHOT artifact is uploaded to
demo-counter-app-snapshotrepository.
-
Also our new docker image is pushed to Nexus Docker Reposiytory.
-
If you want, you can delete all the container with one below command:
docker rm jenkins nexus sonarqube counterApp --force -
You do not need to worry about data, all the data are backed up in docker volume.
-
You can see all the docker volumes using below command:
docker volume ls
-
If you want delete those volume, enter following command:
docker volume rm jenkins_home nexus-data sonarqube_data sonarqube_extensions sonarqube_logs
@CopyRight TheSpiritMan