diff --git a/Jenkinsfile b/Jenkinsfile index bfcf05a1..de566705 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,8 +31,25 @@ pipeline { withCredentials([string(credentialsId: 'sonarqube', variable: 'SONAR_AUTH_TOKEN')]) { sh 'mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}' } + } + + stage('Build and Push Docker Image') { + environment { + DOCKER_IMAGE = "aapurva/onlinebookstore:${BUILD_NUMBER}" + DOCKERHUB_CREDENTIALS = credentials('dockerhub-credentials-id') } - + + steps { + script { + sh 'docker build -t ${DOCKER_IMAGE} .' + def dockerImage = docker.image("${DOCKER_IMAGE}") + docker.withRegistry('https://index.docker.io/v1/', "dockerhub-credentials-id") { + dockerImage.push() + } + } + } + } + } } }