mirror of
https://github.com/spring-projects/spring-petclinic.git
synced 2025-07-21 15:25:49 +00:00
Update Jenkinsfile
This commit is contained in:
parent
007b2c45b4
commit
291e28605f
1 changed files with 14 additions and 4 deletions
18
Jenkinsfile
vendored
18
Jenkinsfile
vendored
|
@ -2,6 +2,10 @@ pipeline {
|
||||||
agent {
|
agent {
|
||||||
label 'mavenbuilder'
|
label 'mavenbuilder'
|
||||||
}
|
}
|
||||||
|
environment {
|
||||||
|
TAG = sh(returnStdout: true, script: "git rev-parse --short HEAD").trim()
|
||||||
|
DOCKER_REGISTRY = "https://hub.docker.com/repository/docker/rgeorgegrid/mr"
|
||||||
|
}
|
||||||
stages {
|
stages {
|
||||||
stage ('Checkstyle') {
|
stage ('Checkstyle') {
|
||||||
steps {
|
steps {
|
||||||
|
@ -30,11 +34,17 @@ pipeline {
|
||||||
stage ('Containerisation') {
|
stage ('Containerisation') {
|
||||||
steps {
|
steps {
|
||||||
script {
|
script {
|
||||||
def dockerImage = docker.build("test-image1:${GIT_COMMIT[0..7]}", '.')
|
def composeBuildOutput = sh(script: 'docker-compose build --quiet', returnStdout: true).trim()
|
||||||
docker.withRegistry('https://hub.docker.com/repository/docker/rgeorgegrid/mr', 'docker_hub_login') {
|
def imageIds = composeBuildOutput.tokenize('\n')
|
||||||
dockerImage.push()
|
|
||||||
|
imageIds.each { imageId ->
|
||||||
|
def serviceName = sh(script: "docker inspect --format='{{index .RepoTags 0}}' $imageId | cut -d':' -f1", returnStdout: true).trim()
|
||||||
|
sh "docker tag $imageId $DOCKER_REGISTRY/$serviceName:$TAG"
|
||||||
|
withCredentials([usernamePassword(credentialsId: 'DOCKERHUB_CREDENTIALS_ID', usernameVariable: 'DOCKER_USERNAME', passwordVariable: 'DOCKER_PASSWORD')]) {
|
||||||
|
sh "docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY"
|
||||||
|
sh "docker push $DOCKER_REGISTRY/$serviceName:$TAG"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
echo 'IMAGES BUILT AND PUSHED TO MR REGISTRY'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue