mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-19 22:15:50 +00:00
Build stage
This commit is contained in:
parent
fda33aa261
commit
59743758cd
1 changed files with 13 additions and 3 deletions
16
Jenkinsfile
vendored
16
Jenkinsfile
vendored
|
@ -27,9 +27,19 @@ pipeline {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def branch = env.BRANCH_NAME
|
def branch = env.BRANCH_NAME
|
||||||
sh """
|
def dockerRepo = (branch == 'main') ? 'main' : 'mr'
|
||||||
echo $BRANCH_NAME
|
def imageTag = "${DOCKER_HUB_USER}/${repo}:${GIT_COMMIT_SHORT}"
|
||||||
"""
|
|
||||||
|
withCredentials([usernamePassword(
|
||||||
|
credentialsId: DOCKERHUB_CREDES,
|
||||||
|
usernameVariable: 'DOCKER_USER',
|
||||||
|
passwordVariable: 'DOCKER_PASS'
|
||||||
|
)]) {
|
||||||
|
echo "Logging in to Docker Hub..."
|
||||||
|
sh "echo $DOCKER_PASS | docker login -u $DOCKER_USER --password-stdin"
|
||||||
|
echo "Pushing Docker image to ${imageTag}"
|
||||||
|
sh "docker push ${imageTag}"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue