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 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
if (options.containsKey('imageTag')) {
imageTags = [ options.get("imageTag", gitRef) ]

View File

@ -44,19 +44,36 @@ String getBuildUser() {
}
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) {
switch (channel) {
case 'develop':
return 'dev'
case 'testing':
case 'staging':
return 'tst'
case 'stable':
case 'master':
return 'stb'
default:
return channel.toLowerCase().replaceAll('(a|e|i|o|u|y_|-| )+', '').take(3)
}