feat(container): add floating latest tag when publishing images

This commit is contained in:
wpetit 2023-11-16 11:27:10 +01:00
parent 758f37e8e4
commit f6d9255c5c
2 changed files with 21 additions and 3 deletions

View File

@ -19,7 +19,8 @@ String buildAndPublishImage(Map options = [:]) {
String imageName = options.get('imageName', '') String imageName = options.get('imageName', '')
String gitRef = sh(returnStdout: true, script: 'git describe --always').trim() String gitRef = sh(returnStdout: true, script: 'git describe --always').trim()
List<String> imageTags = options.get('imageTags', utils.getProjectVersionTags()) List<String> defaultImageTags = utils.getProjectVersionTags() + [ "${utils.getProjectVersionDefaultChannel()}-latest" ]
List<String> imageTags = options.get('imageTags', defaultImageTags)
// Handle legacy imageTag parameter // Handle legacy imageTag parameter
if (options.containsKey('imageTag')) { if (options.containsKey('imageTag')) {
imageTags = [ options.get("imageTag", gitRef) ] imageTags = [ options.get("imageTag", gitRef) ]

View File

@ -44,19 +44,36 @@ String getBuildUser() {
} }
String getProjectVersionDefaultChannel() { String getProjectVersionDefaultChannel() {
return env.BRANCH_NAME.toLowerCase().replaceAll('(_|-| )+', '') switch (env.BRANCH_NAME) {
case 'develop':
return 'develop'
case 'testing':
case 'staging':
return 'testing'
case 'stable':
case 'master':
return 'stable'
default:
return env.BRANCH_NAME.toLowerCase().replaceAll('(_|-| )+', '')
}
} }
String getProjectVersionShortChannel(String channel) { String getProjectVersionShortChannel(String channel) {
switch (channel) { switch (channel) {
case 'develop': case 'develop':
return 'dev' return 'dev'
case 'testing': case 'testing':
case 'staging': case 'staging':
return 'tst' return 'tst'
case 'stable': case 'stable':
case 'master': case 'master':
return 'stb' return 'stb'
default: default:
return channel.toLowerCase().replaceAll('(a|e|i|o|u|y_|-| )+', '').take(3) return channel.toLowerCase().replaceAll('(a|e|i|o|u|y_|-| )+', '').take(3)
} }