fix: publish on custom registry
This commit is contained in:
parent
8e1b257144
commit
14220ae4e3
@ -23,8 +23,6 @@ String buildAndPublishImage(Map options = [:]) {
|
|||||||
passwordVariable: 'HUB_PASSWORD'
|
passwordVariable: 'HUB_PASSWORD'
|
||||||
]),
|
]),
|
||||||
]) {
|
]) {
|
||||||
String fullImageName = "${dockerRepository}/${env.HUB_USERNAME}/${imageName}"
|
|
||||||
|
|
||||||
stage('Validate Dockerfile with Hadolint') {
|
stage('Validate Dockerfile with Hadolint') {
|
||||||
utils.when(!skipVerifications) {
|
utils.when(!skipVerifications) {
|
||||||
runHadolintCheck(dockerfile, projectRepository)
|
runHadolintCheck(dockerfile, projectRepository)
|
||||||
@ -37,7 +35,7 @@ String buildAndPublishImage(Map options = [:]) {
|
|||||||
docker build \
|
docker build \
|
||||||
--build-arg="GIT_USERNAME=${env.GIT_USERNAME}" \
|
--build-arg="GIT_USERNAME=${env.GIT_USERNAME}" \
|
||||||
--build-arg="GIT_PASSWORD=${env.GIT_PASSWORD}" \
|
--build-arg="GIT_PASSWORD=${env.GIT_PASSWORD}" \
|
||||||
-t '${fullImageName}:${imageTag}' \
|
-t '${imageName}:${imageTag}' \
|
||||||
-f '${dockerfile}' \
|
-f '${dockerfile}' \
|
||||||
'${contextDir}'
|
'${contextDir}'
|
||||||
"""
|
"""
|
||||||
@ -46,17 +44,16 @@ String buildAndPublishImage(Map options = [:]) {
|
|||||||
|
|
||||||
stage('Validate image with Trivy') {
|
stage('Validate image with Trivy') {
|
||||||
utils.when(!skipVerifications) {
|
utils.when(!skipVerifications) {
|
||||||
runTrivyCheck("${fullImageName}:${imageTag}", projectRepository)
|
runTrivyCheck("${imageName}:${imageTag}", projectRepository)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stage("Publish image '${fullImageName}:${imageTag}'") {
|
stage("Publish image '${imageName}:${imageTag}'") {
|
||||||
utils.when(!dryRun) {
|
utils.when(!dryRun) {
|
||||||
retry(2) {
|
retry(2) {
|
||||||
sh """
|
sh """
|
||||||
echo ${env.HUB_PASSWORD} | docker login -u '${env.HUB_USERNAME}' --password-stdin
|
echo ${env.HUB_PASSWORD} | docker login -u '${env.HUB_USERNAME}' --password-stdin '${dockerRepository}'
|
||||||
docker login '${dockerRepository}'
|
docker push '${imageName}:${imageTag}'
|
||||||
docker push '${fullImageName}:${imageTag}'
|
|
||||||
"""
|
"""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user