This commit is contained in:
Jamie Curnow
2023-03-08 11:06:05 +10:00
parent 89274ca983
commit b64af6865b

16
Jenkinsfile vendored
View File

@@ -1,3 +1,7 @@
@Field
def shOutput = ""
def buildxPushTags = ""
pipeline { pipeline {
agent { agent {
label 'docker-multiarch' label 'docker-multiarch'
@@ -26,7 +30,7 @@ pipeline {
} }
steps { steps {
script { script {
env.BUILDX_PUSH_TAGS = "-t docker.io/jc21/${IMAGE}:${BUILD_VERSION} -t docker.io/jc21/${IMAGE}:${MAJOR_VERSION} -t docker.io/jc21/${IMAGE}:latest" buildxPushTags = "-t docker.io/jc21/${IMAGE}:${BUILD_VERSION} -t docker.io/jc21/${IMAGE}:${MAJOR_VERSION} -t docker.io/jc21/${IMAGE}:latest"
} }
} }
} }
@@ -39,7 +43,7 @@ pipeline {
steps { steps {
script { script {
// Defaults to the Branch name, which is applies to all branches AND pr's // Defaults to the Branch name, which is applies to all branches AND pr's
env.BUILDX_PUSH_TAGS = "-t docker.io/jc21/${IMAGE}:github-${BRANCH_LOWER}" buildxPushTags = "-t docker.io/jc21/${IMAGE}:github-${BRANCH_LOWER}"
} }
} }
} }
@@ -65,7 +69,7 @@ pipeline {
sh 'docker pull nginxproxymanager/nginx-full:certbot-node' sh 'docker pull nginxproxymanager/nginx-full:certbot-node'
// See: https://github.com/yarnpkg/yarn/issues/3254 // See: https://github.com/yarnpkg/yarn/issues/3254
script { script {
def SHOUTPUT = sh(returnStdout: true, script: '''docker run --rm \\ shOutput = sh(returnStdout: true, script: '''docker run --rm \\
-v "$(pwd)/backend:/app" \\ -v "$(pwd)/backend:/app" \\
-v "$(pwd)/global:/app/global" \\ -v "$(pwd)/global:/app/global" \\
-w /app \\ -w /app \\
@@ -76,7 +80,7 @@ pipeline {
echo 'Docker Build ...' echo 'Docker Build ...'
script { script {
def SHOUTPUT = sh(returnStdout: true, script: '''docker build --pull --no-cache --squash --compress \\ shOutput = sh(returnStdout: true, script: '''docker build --pull --no-cache --squash --compress \\
-t "${IMAGE}:ci-${BUILD_NUMBER}" \\ -t "${IMAGE}:ci-${BUILD_NUMBER}" \\
-f docker/Dockerfile \\ -f docker/Dockerfile \\
--build-arg TARGETPLATFORM=linux/amd64 \\ --build-arg TARGETPLATFORM=linux/amd64 \\
@@ -90,7 +94,7 @@ pipeline {
} }
post { post {
failure { failure {
npmGithubPrComment("CI Error:\n\n```\n${SHOUTPUT}\n```", true) npmGithubPrComment("CI Error:\n\n```\n${shOutput}\n```", true)
} }
} }
} }
@@ -176,7 +180,7 @@ pipeline {
// Docker Login // Docker Login
sh "docker login -u '${duser}' -p '${dpass}'" sh "docker login -u '${duser}' -p '${dpass}'"
// Buildx with push from cache // Buildx with push from cache
sh "./scripts/buildx --push ${BUILDX_PUSH_TAGS}" sh "./scripts/buildx --push ${buildxPushTags}"
} }
} }
} }