ci: enforce default Docker image tags strictly

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-09-26 12:10:23 +02:00
parent 56feedc58a
commit 6072fcbee6
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4

View File

@ -19,7 +19,7 @@ pipeline {
string( string(
name: 'IMAGE_TAG', name: 'IMAGE_TAG',
description: 'Name of Docker tag to push. Optional Parameter.', description: 'Name of Docker tag to push. Optional Parameter.',
defaultValue: params.IMAGE_TAG ?: 'deploy-wakuv2-test', defaultValue: getDefaultImageTag()
) )
string( string(
name: 'IMAGE_NAME', name: 'IMAGE_NAME',
@ -76,6 +76,7 @@ pipeline {
} }
stage('Push') { stage('Push') {
when { expression { params.IMAGE_TAG != '' } }
steps { script { steps { script {
withDockerRegistry([ withDockerRegistry([
credentialsId: params.DOCKER_CRED, url: "" credentialsId: params.DOCKER_CRED, url: ""
@ -86,6 +87,7 @@ pipeline {
} } } }
} }
} // stages } // stages
post { post {
success { script { success { script {
def discord = load 'ci/discord.groovy' def discord = load 'ci/discord.groovy'
@ -97,3 +99,14 @@ pipeline {
always { sh 'docker image prune -f' } always { sh 'docker image prune -f' }
} // post } // post
} // pipeline } // 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 ''
}
}