From ef580e0e5d0264dfe1c7c862b458d406ba1782f1 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 29 Jan 2023 22:42:53 +0100 Subject: [PATCH] Updated to clean and add git restore mtime Modified the pipeline to build and push on the same stage Added a catch error to stop the stage that has an issue but not the rest --- JenkinsFile | 77 +++++++++++++++++++++++++---------------------------- 1 file changed, 36 insertions(+), 41 deletions(-) diff --git a/JenkinsFile b/JenkinsFile index 3a04929c..7575561b 100644 --- a/JenkinsFile +++ b/JenkinsFile @@ -13,74 +13,69 @@ pipeline { agent any environment { DOCKER_GIT_TAG="$AWS_ECR_URL/web3-proxy:${GIT_COMMIT.substring(0,8)}" - DOCKER_LATEST_TAG="$AWS_ECR_URL/web3-proxy:latest" DOCKER_BUILDKIT=1 } stages { - stage('build') { + stage('build and push') { parallel { - stage('Build amd64 image') { - agent {label 'amd64_jenkins_agent'} + stage('Build and push amd64 image') { + agent { + label 'amd64_jenkins_agent' + } steps { script { DOCKER_GIT_TAG_AMD="$DOCKER_GIT_TAG" + "_amd64" restoreMTime() - amd_image = docker.build("$DOCKER_GIT_TAG_AMD") - } - } - } - stage('Build arm64 image') { - agent {label 'arm64_jenkins_agent'} - steps { - script { - DOCKER_GIT_TAG_ARM="$DOCKER_GIT_TAG" + "_arm64" - restoreMTime() - arm_image = docker.build("$DOCKER_GIT_TAG_ARM") - } - } - } - stage('Build intel image') { - agent {label 'intel_jenkins_agent'} - steps { - script { - DOCKER_GIT_TAG_INTEL="$DOCKER_GIT_TAG" + "_intel_sky_lake" - restoreMTime() - intel_image = docker.build("$DOCKER_GIT_TAG_INTEL") - } - } - } - } - } - stage('push') { - parallel { - stage('push amd64 image') { - agent {label 'amd64_jenkins_agent'} - steps { - script { + try { + amd_image = docker.build("$DOCKER_GIT_TAG_AMD") + } catch (e) { + def err = "amd64 build failed: ${e}" + error(err) + } amd_image.push() amd_image.push('latest_amd3') } } } - stage('push arm64 image') { - agent {label 'arm64_jenkins_agent'} + stage('Build and push arm64 image') { + agent { + label 'arm64_jenkins_agent' + } steps { script { + DOCKER_GIT_TAG_ARM="$DOCKER_GIT_TAG" + "_arm64" + restoreMTime() + try { + arm_image = docker.build("$DOCKER_GIT_TAG_ARM") + } catch (e) { + def err = "arm64 build failed: ${e}" + error(err) + } arm_image.push() arm_image.push('latest_graviton2') } } } - stage('push intel image') { - agent {label 'intel_jenkins_agent'} + stage('Build and push intel image') { + agent { + label 'intel_jenkins_agent' + } steps { script { + DOCKER_GIT_TAG_INTEL="$DOCKER_GIT_TAG" + "_intel_sky_lake" + restoreMTime() + try { + intel_image = docker.build("$DOCKER_GIT_TAG_INTEL") + } catch (e) { + def err = "intel_sky_lake build failed: ${e}" + error(err) + } intel_image.push() intel_image.push('latest') } } } } - } + } } }