From 14220ae4e35105896aa30c94769f6ad67157dce7 Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 12 Oct 2022 16:53:23 +0200 Subject: [PATCH] fix: publish on custom registry --- vars/container.groovy | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/vars/container.groovy b/vars/container.groovy index aea4a12..a6d3105 100644 --- a/vars/container.groovy +++ b/vars/container.groovy @@ -23,8 +23,6 @@ String buildAndPublishImage(Map options = [:]) { passwordVariable: 'HUB_PASSWORD' ]), ]) { - String fullImageName = "${dockerRepository}/${env.HUB_USERNAME}/${imageName}" - stage('Validate Dockerfile with Hadolint') { utils.when(!skipVerifications) { runHadolintCheck(dockerfile, projectRepository) @@ -37,7 +35,7 @@ String buildAndPublishImage(Map options = [:]) { docker build \ --build-arg="GIT_USERNAME=${env.GIT_USERNAME}" \ --build-arg="GIT_PASSWORD=${env.GIT_PASSWORD}" \ - -t '${fullImageName}:${imageTag}' \ + -t '${imageName}:${imageTag}' \ -f '${dockerfile}' \ '${contextDir}' """ @@ -46,17 +44,16 @@ String buildAndPublishImage(Map options = [:]) { stage('Validate image with Trivy') { utils.when(!skipVerifications) { - runTrivyCheck("${fullImageName}:${imageTag}", projectRepository) + runTrivyCheck("${imageName}:${imageTag}", projectRepository) } } - stage("Publish image '${fullImageName}:${imageTag}'") { + stage("Publish image '${imageName}:${imageTag}'") { utils.when(!dryRun) { retry(2) { sh """ - echo ${env.HUB_PASSWORD} | docker login -u '${env.HUB_USERNAME}' --password-stdin - docker login '${dockerRepository}' - docker push '${fullImageName}:${imageTag}' + echo ${env.HUB_PASSWORD} | docker login -u '${env.HUB_USERNAME}' --password-stdin '${dockerRepository}' + docker push '${imageName}:${imageTag}' """ } }