mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 23:35:50 +00:00
Update Jenkinsfile for MR
This commit is contained in:
parent
b586cc17df
commit
439d0654a5
1 changed files with 46 additions and 6 deletions
46
Jenkinsfile
vendored
46
Jenkinsfile
vendored
|
@ -36,7 +36,7 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage('Build Docker Image') {
|
stage('Build Docker Image (Main)') {
|
||||||
when {
|
when {
|
||||||
branch 'main'
|
branch 'main'
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,8 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Push Docker Image') {
|
|
||||||
|
stage('Push Docker Image (Main)') {
|
||||||
when {
|
when {
|
||||||
branch 'main'
|
branch 'main'
|
||||||
}
|
}
|
||||||
|
@ -63,7 +64,46 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Build Docker Image (MR)') {
|
||||||
|
when {
|
||||||
|
expression {
|
||||||
|
// Execute this stage only for merge requests
|
||||||
|
return env.CHANGE_ID != null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def gitCommitShort = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||||||
|
appMR = docker.build("${DOCKER_REPO_MR}:${gitCommitShort}")
|
||||||
|
appMR.inside {
|
||||||
|
sh 'echo $(curl localhost:8080)'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Push Docker Image (MR)') {
|
||||||
|
when {
|
||||||
|
expression {
|
||||||
|
// Execute this stage only for merge requests
|
||||||
|
return env.CHANGE_ID != null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def gitCommitShort = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
|
||||||
|
docker.withRegistry('https://registry.hub.docker.com', 'docker_hub_login') {
|
||||||
|
appMR.push("${DOCKER_REPO_MR}:${gitCommitShort}")
|
||||||
|
appMR.push("latest")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
cleanWs() // Clean workspace after the pipeline execution
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue