Skip to content

Commit

Permalink
Fix image push step
Browse files Browse the repository at this point in the history
  • Loading branch information
maricaantonacci committed Apr 16, 2024
1 parent 8a5c145 commit ad817e7
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ pipeline {

environment {

//DOCKER_HUB_CREDENTIALS = 'docker-hub-credentials'
DOCKER_HUB_CREDENTIALS = 'docker-hub-credentials'
HARBOR_CREDENTIALS = 'harbor-paas-credentials'
DOCKER_HUB_IMAGE_NAME = 'indigo-paas/orchestrator-dashboard'
DOCKER_HUB_IMAGE_NAME = 'indigopaas/orchestrator-dashboard'
HARBOR_IMAGE_NAME = 'datacloud-middleware/orchestrator-dashboard'
}

Expand All @@ -17,13 +17,10 @@ pipeline {
steps {
script {
// Build Docker image
def dockerImage = docker.build("${DOCKER_HUB_IMAGE_NAME}:${env.BRANCH_NAME}", "-f docker/Dockerfile .")

// Tag the image for Harbor
dockerImage.tag("${HARBOR_IMAGE_NAME}:${env.BRANCH_NAME}")

// Export the Docker image object for later stages
env.DOCKER_IMAGE = dockerImage.id
def dockerImage = docker.build("orchestrator-dashboard:${env.BRANCH_NAME}", "-f docker/Dockerfile .")

sh("docker tag orchestrator-dashboard:${env.BRANCH_NAME} ${HARBOR_IMAGE_NAME}:${env.BRANCH_NAME}")
sh("docker tag orchestrator-dashboard:${env.BRANCH_NAME} ${DOCKER_HUB_IMAGE_NAME}:${env.BRANCH_NAME}")
}
}
}
Expand All @@ -34,12 +31,12 @@ pipeline {
steps {
script {
// Retrieve the Docker image object from the previous stage
def dockerImage = docker.image(env.DOCKER_IMAGE)
def dockerhubImage = docker.image("${DOCKER_HUB_IMAGE_NAME}:${env.BRANCH_NAME}")

// Login to Docker Hub
docker.withRegistry('https://index.docker.io/v1/', DOCKER_HUB_CREDENTIALS) {
// Push the Docker image to Docker Hub
dockerImage.push()
dockerhubImage.push()
}
}
}
Expand All @@ -49,12 +46,12 @@ pipeline {
steps {
script {
// Retrieve the Docker image object from the previous stage
def dockerImage = docker.image(env.DOCKER_IMAGE)
def harborImage = docker.image("${HARBOR_IMAGE_NAME}:${env.BRANCH_NAME}")

// Login to Harbor
docker.withRegistry('https://harbor.cloud.infn.it', HARBOR_CREDENTIALS) {
// Push the Docker image to Harbor
dockerImage.push()
harborImage.push()
}
}
}
Expand Down

0 comments on commit ad817e7

Please sign in to comment.