bci2: Add defaultBranch keyword argument
Passing the `defaultBranch` argument to `buildContainerImage2()` allows setting the `latest` for projects where the default branch is not *main*. For example: ```groovy buildContainerImage2(defaultBranch: 'master') ``` This will update the `latest` tag whenever a new build is created on the *master* branch.bci2-resources
parent
008bae5cee
commit
6cc6c5ef36
|
@ -7,6 +7,7 @@ def call(args) {
|
||||||
def tag = args?.tag
|
def tag = args?.tag
|
||||||
def archlist = args?.archlist
|
def archlist = args?.archlist
|
||||||
def schedule = args?.schedule
|
def schedule = args?.schedule
|
||||||
|
def defaultBranch = args?.defaultBranch
|
||||||
|
|
||||||
properties([
|
properties([
|
||||||
pipelineTriggers([cron(schedule ?: 'H H H * *')])
|
pipelineTriggers([cron(schedule ?: 'H H H * *')])
|
||||||
|
@ -27,6 +28,9 @@ def call(args) {
|
||||||
if (archlist == null) {
|
if (archlist == null) {
|
||||||
archlist = ['amd64']
|
archlist = ['amd64']
|
||||||
}
|
}
|
||||||
|
if (defaultBranch == null) {
|
||||||
|
defaultBranch = 'main'
|
||||||
|
}
|
||||||
def repo = "${registry}/${project}/${name}"
|
def repo = "${registry}/${project}/${name}"
|
||||||
def full_name = "${repo}:${tag}"
|
def full_name = "${repo}:${tag}"
|
||||||
|
|
||||||
|
@ -72,7 +76,7 @@ def call(args) {
|
||||||
}
|
}
|
||||||
sh "buildah push ${full_name} ${full_name}-${env.BUILD_NUMBER}"
|
sh "buildah push ${full_name} ${full_name}-${env.BUILD_NUMBER}"
|
||||||
sh "buildah push ${full_name}"
|
sh "buildah push ${full_name}"
|
||||||
if (env.BRANCH_NAME == 'main') {
|
if (env.BRANCH_NAME == defaultBranch) {
|
||||||
sh "buildah push ${full_name} ${repo}:latest"
|
sh "buildah push ${full_name} ${repo}:latest"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue