File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -47,15 +47,17 @@ pipeline {
4747 }
4848 }
4949
50- stage(' Push' ) {
51- agent any
50+ stage(' Push to Docker Hub' ) {
5251 steps {
53- withCredentials([usernamePassword(credentialsId : ' dockerHub' , passwordVariable : ' dockerHubPassword' , usernameVariable : ' dockerHubUser' )]) {
54- sh '''
55- docker login -u ${env.dockerHubUser} -p ${env.dockerHubPassword}
56- docker image tag ${docker_image}:v1
57- dockr push ${docker_image}:v1
58- '''
52+ // Use withCredentials to access Docker Hub credentials
53+ withCredentials([usernamePassword(credentialsId : ' dockerHub' , usernameVariable : ' DOCKER_USER' , passwordVariable : ' DOCKER_PASS' )]) {
54+ script {
55+ // Log in to Docker Hub
56+ sh ' echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin'
57+ sh ' docker build -t ${docker_image}:v1'
58+ // Push the image
59+ sh ' docker push ${docker_image}:v1'
60+ }
5961 }
6062 }
6163 }
You can’t perform that action at this time.
0 commit comments