Skip to content

Commit 4ececfd

Browse files
author
xiaoqunLiu
committed
upload image
1 parent 6345027 commit 4ececfd

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

Jenkinsfile

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,33 @@ pipeline {
4242
}
4343
}
4444
// Uploading Docker images into Docker Hub
45+
// stage('Upload image') {
46+
// steps {
47+
// script {
48+
// // sign in Docker Hub
49+
// docker.withRegistry('https://registry.hub.docker.com', 'dockerhub_credentials') {
50+
// // push image
51+
// docker.image("${env.DOCKER_IMAGE}:${env.DOCKER_TAG}").push()
52+
// // :optional: label latest
53+
// docker.image("${env.DOCKER_IMAGE}:${env.DOCKER_TAG}").push('latest')
54+
// }
55+
// }
56+
// }
57+
// }
58+
4559
stage('Upload image') {
4660
steps {
47-
script {
48-
// sign in Docker Hub
49-
docker.withRegistry('https://registry.hub.docker.com', 'dockerhub_credentials') {
50-
// push image
51-
docker.image("${env.DOCKER_IMAGE}:${env.DOCKER_TAG}").push()
52-
// :optional: label latest
53-
docker.image("${env.DOCKER_IMAGE}:${env.DOCKER_TAG}").push('latest')
54-
}
61+
withCredentials([usernamePassword(credentialsId: 'dockerhub_credentials', usernameVariable: 'DOCKER_USER', passwordVariable: 'DOCKER_PASS')]) {
62+
sh '''
63+
echo "$DOCKER_PASS" | docker login -u "$DOCKER_USER" --password-stdin
64+
docker push shawnliu2333/teedy:${BUILD_NUMBER}
65+
docker tag shawnliu2333/teedy:${BUILD_NUMBER} shawnliu2333/teedy:latest
66+
docker push shawnliu2333/teedy:latest
67+
'''
5568
}
5669
}
5770
}
71+
5872
// Running Docker container
5973
stage('Run containers') {
6074
steps {

0 commit comments

Comments
 (0)