mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-07 16:33:08 +00:00
ci: use latest and stable Docker tags based on job name
Also use Git commit by default if no tag is provided, but do not push. Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
9f4754dcae
commit
735c2fa0d7
@ -17,7 +17,7 @@ pipeline {
|
|||||||
string(
|
string(
|
||||||
name: 'IMAGE_TAG',
|
name: 'IMAGE_TAG',
|
||||||
description: 'Docker image tag.',
|
description: 'Docker image tag.',
|
||||||
defaultValue: env.JOB_BASE_NAME == 'release' ? 'stable' : 'deploy-test',
|
defaultValue: getDefaultImageTag()
|
||||||
)
|
)
|
||||||
string(
|
string(
|
||||||
name: 'DOCKER_CRED',
|
name: 'DOCKER_CRED',
|
||||||
@ -38,20 +38,21 @@ pipeline {
|
|||||||
stage('Build') {
|
stage('Build') {
|
||||||
steps { script {
|
steps { script {
|
||||||
image = docker.build(
|
image = docker.build(
|
||||||
"${params.IMAGE_NAME}:${params.IMAGE_TAG}",
|
"${params.IMAGE_NAME}:${params.IMAGE_TAG ?: GIT_COMMIT.take(8)}",
|
||||||
"--build-arg='GIT_COMMIT=${GIT_COMMIT.take(8)}' ."
|
"--build-arg='GIT_COMMIT=${GIT_COMMIT.take(8)}' ."
|
||||||
)
|
)
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
|
|
||||||
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: ''
|
||||||
]) {
|
]) {
|
||||||
image.push()
|
image.push()
|
||||||
/* If Git ref is a tag push it as Docker tag too. */
|
/* If Git ref is a tag push it as Docker tag too. */
|
||||||
if (env.GIT_BRANCH ==~ /v\d+\.\d+\.\d+.*/) {
|
if (params.GIT_REF ==~ /v\d+\.\d+\.\d+.*/) {
|
||||||
image.push(params.GIT_REF)
|
image.push(params.GIT_REF)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -107,3 +108,11 @@ def discordNotify(Map args=[:]) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def getDefaultImageTag() {
|
||||||
|
switch (env.JOB_BASE_NAME) {
|
||||||
|
case 'docker-latest': return 'latest'
|
||||||
|
case 'docker-release': return 'stable'
|
||||||
|
default: return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user