From b563bbcca8eb50980e8dd1e2f6f97e9766e63b98 Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Wed, 25 Oct 2023 15:07:05 +0200 Subject: [PATCH] build(hb): add jenkins example Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- content/build/hydrobuild.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/content/build/hydrobuild.md b/content/build/hydrobuild.md index e1c30628837..69dec003e22 100644 --- a/content/build/hydrobuild.md +++ b/content/build/hydrobuild.md @@ -432,6 +432,42 @@ docker buildx build \ . ``` +{{< /tab >}} +{{< tab name="Jenkins" >}} + +```groovy +pipeline { + agent any + + environment { + ARCH = 'amd64' + DOCKER_PAT = credentials('docker-personal-access-token') + DOCKER_USER = credentials('docker-username') + DOCKER_ORG = '' + IMAGE_NAME = '' + } + + stages { + stage('Build') { + environment { + BUILDX_URL = sh (returnStdout: true, script: 'curl -s https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json | jq -r ".latest.assets[] | select(endswith(\\"linux-$ARCH\\"))"').trim() + } + steps { + sh 'mkdir -vp ~/.docker/cli-plugins/' + sh 'curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL' + sh 'chmod a+x ~/.docker/cli-plugins/docker-buildx' + sh 'echo "$DOCKER_PAT" | docker login --username $DOCKER_USER --password-stdin' + sh 'docker buildx create --use --driver cloud "$DOCKER_ORG/default"' + // Cache-only build + sh 'docker buildx build --platform linux/amd64,linux/arm64 --tag "$IMAGE_NAME" --output type=cacheonly .' + // Build and push a multi-platform image + sh 'docker buildx build --platform linux/amd64,linux/arm64 --push --tag "$IMAGE_NAME" .' + } + } + } +} +``` + {{< /tab >}} {{< tab name="Shell" >}}