feat(container): add floating latest tag when publishing images
This commit is contained in:
parent
758f37e8e4
commit
f6d9255c5c
|
@ -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) ]
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue