ac2c053519
New stage has been added to check if there is a old build from the same job running If yes, it cancel the old one and keep the new one running Co-authored-by: Ben <ben@MB.local>
71 lines
2.2 KiB
Groovy
71 lines
2.2 KiB
Groovy
@Library('jenkins_lib@main') _
|
|
|
|
pipeline {
|
|
agent {
|
|
// not strictly required, but we only build graviton2 right now so this keeps the jenkins-agent count down
|
|
label 'arm64_graviton2'
|
|
}
|
|
options {
|
|
ansiColor('xterm')
|
|
}
|
|
environment {
|
|
// AWS_ECR_URL needs to be set in jenkin's config.
|
|
// AWS_ECR_URL could really be any docker registry. we just use ECR so that we don't have to manage it
|
|
|
|
REPO_NAME="web3-proxy"
|
|
|
|
// branch that should get tagged with "latest_$arch" (stable, main, master, etc.)
|
|
LATEST_BRANCH="main"
|
|
}
|
|
stages {
|
|
stage('Check and Cancel Old Builds') {
|
|
steps {
|
|
script {
|
|
def currentBuildNumber = currentBuild.number
|
|
|
|
// Check all build from same project
|
|
for (build in currentBuild.rawBuild.getParent().getBuilds()) {
|
|
// Check if an older build is still running and cancel it in favor of the new one
|
|
if (build.number < currentBuildNumber && build.building) {
|
|
echo "Cancelling build ${build.number}"
|
|
build.doStop()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('build and push') {
|
|
parallel {
|
|
stage('Build and push arm64_graviton2 image') {
|
|
agent {
|
|
label 'arm64_graviton2'
|
|
}
|
|
environment {
|
|
ARCH="arm64_graviton2"
|
|
}
|
|
steps {
|
|
script {
|
|
myBuildandPush.buildAndPush()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
stage('push latest') {
|
|
parallel {
|
|
stage('maybe push latest_arm64_graviton2 tag') {
|
|
agent any
|
|
environment {
|
|
ARCH="arm64_graviton2"
|
|
}
|
|
steps {
|
|
script {
|
|
myPushLatest.maybePushLatest()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|