forked from rajakumarguptatechie/jenkins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile-docker-integration
35 lines (35 loc) · 1.28 KB
/
Jenkinsfile-docker-integration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
pipeline {
agent {
node {
label 'dockerhost'
}
}
stages {
stage('Download Docker Code From Github') {
steps {
git branch: 'master', credentialsId: 'jenkins-github-credential', url: 'https://github.com/rajakumarguptatechie/docker.git'
}
}
stage('Docker Image Build and Tag') {
steps {
sh """
cd websiteVisitCount
docker build -t websitevisitcount:${BUILD_NUMBER} .
docker tag websitevisitcount:${BUILD_NUMBER} rajakumargupta/websitevisitcount:${BUILD_NUMBER}
"""
}
}
stage('Docker Image Upload to Repository') {
steps {
withCredentials([usernamePassword(credentialsId: 'jenkins-dockerhub-credential', passwordVariable: 'passWord', usernameVariable: 'userName')]) {
sh "docker push rajakumargupta/websitevisitcount:${BUILD_NUMBER}"
}
}
}
stage('Docker Image Cleanup from Local host') {
steps {
sh "docker rmi rajakumargupta/websitevisitcount:${BUILD_NUMBER} && docker rmi websitevisitcount:${BUILD_NUMBER}"
}
}
}
}