From 6072fcbee6aff47c65598f4d74a06f998daaaf87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 26 Sep 2023 12:10:23 +0200 Subject: [PATCH] ci: enforce default Docker image tags strictly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.release | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ci/Jenkinsfile.release b/ci/Jenkinsfile.release index 25ec1bb8e..fe24d916b 100644 --- a/ci/Jenkinsfile.release +++ b/ci/Jenkinsfile.release @@ -19,7 +19,7 @@ pipeline { string( name: 'IMAGE_TAG', description: 'Name of Docker tag to push. Optional Parameter.', - defaultValue: params.IMAGE_TAG ?: 'deploy-wakuv2-test', + defaultValue: getDefaultImageTag() ) string( name: 'IMAGE_NAME', @@ -76,6 +76,7 @@ pipeline { } stage('Push') { + when { expression { params.IMAGE_TAG != '' } } steps { script { withDockerRegistry([ credentialsId: params.DOCKER_CRED, url: "" @@ -86,6 +87,7 @@ pipeline { } } } } // stages + post { success { script { def discord = load 'ci/discord.groovy' @@ -97,3 +99,14 @@ pipeline { always { sh 'docker image prune -f' } } // post } // pipeline + +def getDefaultImageTag() { + if (env.JOB_BASE_NAME) { + return env.JOB_BASE_NAME + } + switch (env.JOB_BASE_NAME) { + case 'docker-latest': return 'latest' + case 'docker-release': return 'stable' + default: return '' + } +}