|
| 1 | +def gitBranch = env.BRANCH_NAME |
| 2 | +def imageName = "memphis-http-proxy" |
| 3 | +def gitURL = "[email protected]:Memphisdev/memphis-http-proxy.git" |
| 4 | +def repoUrlPrefix = "memphisos" |
| 5 | + |
| 6 | +node { |
| 7 | + git credentialsId: 'main-github', url: gitURL, branch: gitBranch |
| 8 | + |
| 9 | + try{ |
| 10 | + |
| 11 | + stage('Login to Docker Hub') { |
| 12 | + withCredentials([usernamePassword(credentialsId: 'docker-hub', usernameVariable: 'DOCKER_HUB_CREDS_USR', passwordVariable: 'DOCKER_HUB_CREDS_PSW')]) { |
| 13 | + sh 'docker login -u $DOCKER_HUB_CREDS_USR -p $DOCKER_HUB_CREDS_PSW' |
| 14 | + } |
| 15 | + } |
| 16 | + |
| 17 | + |
| 18 | + stage('Build and push image to Docker Hub') { |
| 19 | + sh "docker buildx use builder" |
| 20 | + sh "docker buildx build --push --tag ${repoUrlPrefix}/${imageName} --platform linux/amd64,linux/arm64 ." |
| 21 | + } |
| 22 | + |
| 23 | + notifySuccessful() |
| 24 | + |
| 25 | + } |
| 26 | + catch (e) { |
| 27 | + currentBuild.result = "FAILED" |
| 28 | + cleanWs() |
| 29 | + notifyFailed() |
| 30 | + throw e |
| 31 | + } |
| 32 | +} |
| 33 | + def notifySuccessful() { |
| 34 | + emailext ( |
| 35 | + subject: "SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", |
| 36 | + body: """SUCCESSFUL: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': |
| 37 | + Check console output and connection attributes at ${env.BUILD_URL}""", |
| 38 | + recipientProviders: [requestor()] |
| 39 | + ) |
| 40 | +} |
| 41 | +def notifyFailed() { |
| 42 | + emailext ( |
| 43 | + subject: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", |
| 44 | + body: """FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]': |
| 45 | + Check console output at ${env.BUILD_URL}""", |
| 46 | + recipientProviders: [requestor()] |
| 47 | + ) |
| 48 | +} |
| 49 | + |
0 commit comments