From 8fc32c49ad3a7bab23c112920d2a1bf33fe405fb Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 27 Jan 2023 17:45:08 +0100 Subject: [PATCH 1/7] feat: New CI with Jenkinsfile --- Jenkinsfile | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..eb0f5bd5 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,77 @@ +def amd_image +def arm_image +def intel_image + + +pipeline { + agent any + environment { + DOCKER_GIT_TAG="$AWS_ECR_URL/$JOB_BASE_NAME:${$GIT_COMMIT.substring(0,8)}" + DOCKER_LATEST_TAG="$AWS_ECR_URL/$JOB_BASE_NAME:latest" + DOCKER_BUILDKIT=1 + } + stages { + stage('build') { + parallel { + stage('Build amd64 image') { + agent {label 'amd64_jenkins_agent'} + steps { + script { + DOCKER_GIT_TAG_AMD="$DOCKER_GIT_TAG" + "_amd64" + 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" + 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" + intel_image = docker.build("$DOCKER_GIT_TAG_INTEL") + } + } + } + } + } + stage('push') { + parallel { + stage('push amd64 image') { + agent {label 'amd64_jenkins_agent'} + steps { + script { + amd_image.push() + amd_image.push('latest_amd3') + } + } + } + stage('push arm64 image') { + agent {label 'arm64_jenkins_agent'} + steps { + script { + arm_image.push() + arm_image.push('latest_graviton2') + } + } + } + stage('push intel image') { + agent {label 'intel_jenkins_agent'} + steps { + script { + intel_image.push() + intel_image.push('latest') + } + } + } + } + } + } +} \ No newline at end of file From b116c19c9ed888981de63c7b1b0a1304ea7abfcc Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 28 Jan 2023 10:08:56 +0100 Subject: [PATCH 2/7] Fix .git folder timestamps using 'git restore-mtime' --- Jenkinsfile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index eb0f5bd5..0a7e4a4d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,12 @@ def amd_image def arm_image def intel_image +def restoreMTime() { + sh ''' + git restore-mtime + touch -t $(git show -s --date=format:'%Y%m%d%H%M.%S' --format=%cd HEAD) .git + ''' +} pipeline { @@ -18,6 +24,7 @@ pipeline { steps { script { DOCKER_GIT_TAG_AMD="$DOCKER_GIT_TAG" + "_amd64" + restoreMTime() amd_image = docker.build("$DOCKER_GIT_TAG_AMD") } } @@ -27,6 +34,7 @@ pipeline { steps { script { DOCKER_GIT_TAG_ARM="$DOCKER_GIT_TAG" + "_arm64" + restoreMTime() arm_image = docker.build("$DOCKER_GIT_TAG_ARM") } } @@ -36,6 +44,7 @@ pipeline { steps { script { DOCKER_GIT_TAG_INTEL="$DOCKER_GIT_TAG" + "_intel_sky_lake" + restoreMTime() intel_image = docker.build("$DOCKER_GIT_TAG_INTEL") } } From c1efe760acbaf4b62db9f51d47314c2d6f92d437 Mon Sep 17 00:00:00 2001 From: Bencyril Date: Sat, 28 Jan 2023 10:48:58 +0100 Subject: [PATCH 3/7] Name typo --- Jenkinsfile => JenkinsFile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename Jenkinsfile => JenkinsFile (99%) diff --git a/Jenkinsfile b/JenkinsFile similarity index 99% rename from Jenkinsfile rename to JenkinsFile index 0a7e4a4d..795488b8 100644 --- a/Jenkinsfile +++ b/JenkinsFile @@ -83,4 +83,4 @@ pipeline { } } } -} \ No newline at end of file +} From dc51c6944da4077f7ec0b83c6d97740aab29a5c9 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 28 Jan 2023 11:21:01 +0100 Subject: [PATCH 4/7] Typo DOCKER_GIT_TAG env var --- JenkinsFile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JenkinsFile b/JenkinsFile index 795488b8..d62fa770 100644 --- a/JenkinsFile +++ b/JenkinsFile @@ -12,7 +12,7 @@ def restoreMTime() { pipeline { agent any environment { - DOCKER_GIT_TAG="$AWS_ECR_URL/$JOB_BASE_NAME:${$GIT_COMMIT.substring(0,8)}" + DOCKER_GIT_TAG="$AWS_ECR_URL/$JOB_BASE_NAME:${GIT_COMMIT.substring(0,8)}" DOCKER_LATEST_TAG="$AWS_ECR_URL/$JOB_BASE_NAME:latest" DOCKER_BUILDKIT=1 } From a883bb99f1897debb14510baafbea0581cf6338c Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 29 Jan 2023 09:06:02 +0100 Subject: [PATCH 5/7] With multibranch JOB_NAME isn't repo's name --- JenkinsFile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/JenkinsFile b/JenkinsFile index d62fa770..3a04929c 100644 --- a/JenkinsFile +++ b/JenkinsFile @@ -12,8 +12,8 @@ def restoreMTime() { pipeline { agent any environment { - DOCKER_GIT_TAG="$AWS_ECR_URL/$JOB_BASE_NAME:${GIT_COMMIT.substring(0,8)}" - DOCKER_LATEST_TAG="$AWS_ECR_URL/$JOB_BASE_NAME:latest" + 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 { From ef580e0e5d0264dfe1c7c862b458d406ba1782f1 Mon Sep 17 00:00:00 2001 From: Ben Date: Sun, 29 Jan 2023 22:42:53 +0100 Subject: [PATCH 6/7] 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') } } } } - } + } } } From ed5907feabd564ca56aca180b16a9295f2042b0e Mon Sep 17 00:00:00 2001 From: Ben Date: Mon, 30 Jan 2023 15:33:01 +0100 Subject: [PATCH 7/7] Rename Jenkinsfile to be standard with other --- JenkinsFile => Jenkinsfile | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename JenkinsFile => Jenkinsfile (100%) diff --git a/JenkinsFile b/Jenkinsfile similarity index 100% rename from JenkinsFile rename to Jenkinsfile