fix: publish on custom registry

This commit is contained in:
wpetit 2022-10-12 16:53:23 +02:00
parent 8e1b257144
commit 14220ae4e3

View File

@ -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}'
"""
}
}