From 6550565afca608448495abb6b14d1fc476849592 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 18 Apr 2023 18:26:43 +0200 Subject: [PATCH] ci: adjust Docker Jenkinsfile for releases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changes: * Rename `BRANCH` to `GIT_REF` to indicate tags can be used. * Default to `stable` for `IMAGE_TAG` on release builds. * Use `GIT_REF` for specific Docker image tag instead of commit. * Adjust some comments and descriptions. Resolves: https://github.com/waku-org/go-waku/issues/516 Signed-off-by: Jakub SokoĊ‚owski --- ci/Jenkinsfile.docker | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ci/Jenkinsfile.docker b/ci/Jenkinsfile.docker index 94edf4b4..615fe562 100644 --- a/ci/Jenkinsfile.docker +++ b/ci/Jenkinsfile.docker @@ -5,9 +5,9 @@ pipeline { parameters { string( - name: 'BRANCH', + name: 'GIT_REF', defaultValue: 'master', - description: 'Name of branch to build.' + description: 'Branch, tag, or commit to build.' ) string( name: 'IMAGE_NAME', @@ -16,8 +16,8 @@ pipeline { ) string( name: 'IMAGE_TAG', - defaultValue: 'deploy-test', - description: 'Docker image name.', + defaultValue: env.JOB_BASE_NAME == 'release' ? 'stable' : 'deploy-test', + description: 'Docker image tag.', ) } @@ -32,8 +32,12 @@ pipeline { stages { stage('Build') { steps { script { + def imageTag = GIT_COMMIT.take(8) + if (env.JOB_BASE_NAME == 'release') { + imageTag = params.GIT_REF + } image = docker.build( - "${params.IMAGE_NAME}:${GIT_COMMIT.take(8)}", + "${params.IMAGE_NAME}:${imageTag}", "--build-arg='GIT_COMMIT=${GIT_COMMIT.take(8)}' ." ) } } @@ -62,7 +66,7 @@ pipeline { post { success { script { discordNotify( - header: 'Go-Waku deployment successful!', + header: 'Go-Waku build successful!', cred: 'discord-waku-deployments-webhook', ) } }