File tree Expand file tree Collapse file tree 1 file changed +22
-8
lines changed
Expand file tree Collapse file tree 1 file changed +22
-8
lines changed Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments