mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-22 15:55:49 +00:00
Update Jenkinsfile
This commit is contained in:
parent
3bda3fccf7
commit
6eec52bfce
1 changed files with 12 additions and 13 deletions
25
Jenkinsfile
vendored
25
Jenkinsfile
vendored
|
@ -43,15 +43,15 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Tag the docker image for merge request repo - mr') {
|
stage('Tag the docker image') {
|
||||||
steps {
|
when {
|
||||||
echo "now we will tag the docker image"
|
|
||||||
when {
|
|
||||||
// Condition to execute the stage when the branch is main
|
// Condition to execute the stage when the branch is main
|
||||||
expression {
|
expression {
|
||||||
return (env.CHANGE_ID == null && env.BRANCH_NAME == 'main')
|
return (env.CHANGE_ID == null && env.BRANCH_NAME == 'main')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
steps {
|
||||||
|
echo "now we will tag the docker image"
|
||||||
script {
|
script {
|
||||||
def imageTag = sh(script: 'docker tag imagine_spring_petclinic:0.1 mihaivalentingeorgescu/mr:0.1', returnStatus: true)
|
def imageTag = sh(script: 'docker tag imagine_spring_petclinic:0.1 mihaivalentingeorgescu/mr:0.1', returnStatus: true)
|
||||||
if (imageTag == 0) {
|
if (imageTag == 0) {
|
||||||
|
@ -66,7 +66,7 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
echo "now we will login to dockerhub"
|
echo "now we will login to dockerhub"
|
||||||
script {
|
script {
|
||||||
def loginDocker = sh(script: 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR -p ', returnStatus: true)
|
def loginDocker = sh(script: 'echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin', returnStatus: true)
|
||||||
if (loginDocker == 0) {
|
if (loginDocker == 0) {
|
||||||
echo "Login ended successfully"
|
echo "Login ended successfully"
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,13 +75,13 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Push to DockerHub to merge rewuest repo - mr') {
|
stage('Push to DockerHub') {
|
||||||
when {
|
when {
|
||||||
// Condition to execute the stage when the branch is main
|
// Condition to execute the stage when the branch is main
|
||||||
expression {
|
expression {
|
||||||
return (env.CHANGE_ID == null && env.BRANCH_NAME == 'main')
|
return (env.CHANGE_ID == null && env.BRANCH_NAME == 'main')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
steps {
|
steps {
|
||||||
echo "now we will push to the docker file"
|
echo "now we will push to the docker file"
|
||||||
script {
|
script {
|
||||||
|
@ -105,7 +105,6 @@ pipeline {
|
||||||
expression {
|
expression {
|
||||||
return env.CHANGE_ID != null
|
return env.CHANGE_ID != null
|
||||||
}
|
}
|
||||||
}
|
|
||||||
steps {
|
steps {
|
||||||
echo "now we will tag the docker image for the main branch"
|
echo "now we will tag the docker image for the main branch"
|
||||||
script {
|
script {
|
||||||
|
@ -119,13 +118,13 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage('Push docker image to main repository') {
|
stage('Push docker image to main repository') {
|
||||||
steps {
|
when {
|
||||||
echo "now we will push the image to the docker main repository"
|
|
||||||
when {
|
|
||||||
// Condition to execute the stage on a pull request event
|
// Condition to execute the stage on a pull request event
|
||||||
expression {
|
expression {
|
||||||
return env.CHANGE_ID != null
|
return env.CHANGE_ID != null
|
||||||
}
|
}
|
||||||
|
steps {
|
||||||
|
echo "now we will push the image to the docker main repository"
|
||||||
script {
|
script {
|
||||||
def pushDockerImageToMain = sh(script: 'docker push mihaivalentingeorgescu/main:0.1', returnStatus: true)
|
def pushDockerImageToMain = sh(script: 'docker push mihaivalentingeorgescu/main:0.1', returnStatus: true)
|
||||||
if (pushDockerImageToMain == 0) {
|
if (pushDockerImageToMain == 0) {
|
||||||
|
|
Loading…
Reference in a new issue