From 4d1a7f822c5cbeacef5c89f1d1c0774ee862e04e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Tue, 21 May 2024 08:35:17 +0200 Subject: [PATCH] ci: use harbor.status.im to push docker images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/waku-org/storenode-messages-counter/issues/9 Signed-off-by: Jakub SokoĊ‚owski --- Dockerfile | 1 + Jenkinsfile | 40 ++++++++++++++++++---------------------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/Dockerfile b/Dockerfile index 94e137c..a62ab95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ FROM alpine:3.14 LABEL maintainer="jakub@status.im" LABEL source="https://github.com/status-im/telemetry" LABEL description="Opt-in message reliability metrics service" +LABEL commit="unknown" COPY --from=builder /go/src/github.com/status-im/telemetry/build/server /usr/local/bin/telemetry diff --git a/Jenkinsfile b/Jenkinsfile index 034555f..68413e9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -2,10 +2,10 @@ pipeline { agent { label 'linux' } parameters { - booleanParam( - name: 'DEPLOY', - description: 'Enable to deploye the Docker image.', - defaultValue: false, + string( + name: 'IMAGE_TAG', + defaultValue: params.IMAGE_TAG ?: 'latest', + description: 'Optional Docker image tag to push.' ) } @@ -20,33 +20,29 @@ pipeline { } environment { - IMAGE_NAME = "statusteam/telemetry" + DOCKER_REGISTRY = 'harbor.status.im' + IMAGE_NAME = "wakuorg/telemetry" IMAGE_DEFAULT_TAG = "${env.GIT_COMMIT.take(7)}" - IMAGE_DEPLOY_TAG = "deploy" } stages { - stage('Build') { steps { script { - image = docker.build( - "${env.IMAGE_NAME}:${env.IMAGE_DEFAULT_TAG}" - ) - } } } - - stage('Push') { steps { script { - withDockerRegistry([ - credentialsId: "dockerhub-statusteam-auto" - ]) { - image.push() - } - } } } + stage('Build') { + steps { script { + image = docker.build( + "${DOCKER_REGISTRY}/${IMAGE_NAME}:${IMAGE_DEFAULT_TAG}", + "--build-arg='commit=${GIT_COMMIT}' .", + ) + } } + } stage('Deploy') { - when { expression { params.DEPLOY } } + when { expression { params.IMAGE_TAG != '' } } steps { script { withDockerRegistry([ - credentialsId: "dockerhub-statusteam-auto" + credentialsId: 'harbor-telemetry-robot', + url: 'https://${DOCKER_REGISTRY}', ]) { - image.push(env.IMAGE_DEPLOY_TAG) + image.push(env.IMAGE_TAG) } } } } } // stages