Jenkins: add support to specify build node per individual job

buildPackage() now has an additional parameter named "buildLabel" that is used
to determine/define where a particular job must be executed.

This defaults to ec2_amd64 which was always the default.
This commit is contained in:
Christian Breunig 2023-07-08 19:51:25 +02:00
parent 08c58c8d65
commit 5a81df9561

View File

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesPattern="**") {
def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesPattern="**", buildLabel="ec2_amd64") {
// - description: Arbitrary text to print on Jenkins Job Description
// instead of package name
// - pkgList: Multiple packages can be build at once in a single Pipeline run
@ -23,6 +23,9 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
// - buildArm: package will also be build for the arm64 platform
// - changesPattern: package will only be build if a change file matching this
// pattern is found
// - buildLabel: used to describe where the job should run. amd64 inside the
// string will be replaced with arm64 when those builds are enabled.
// Example: ec2_amd64 -> ec2_arm64 or foo_amd64 -> foo_arm64
setDescription(description)
@ -37,7 +40,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
stages {
stage('Define Agent') {
agent {
label "ec2_amd64"
label "${buildLabel}"
}
when {
anyOf {
@ -75,7 +78,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
stage('amd64') {
agent {
docker {
label "ec2_amd64"
label "${buildLabel}"
args "${env.DOCKER_ARGS}"
image "${env.DOCKER_IMAGE}"
alwaysPull true
@ -104,7 +107,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
stage('arm64') {
agent {
docker {
label "ec2_arm64"
label "${buildLabel.replace('amd64', 'arm64')}"
args "${env.DOCKER_ARGS}"
image "${env.DOCKER_IMAGE}-arm64"
alwaysPull true
@ -136,7 +139,7 @@ def call(description=null, pkgList=null, buildCmd=null, buildArm=false, changesP
}
}
agent {
label "ec2_amd64"
label "${buildLabel}"
}
steps {
script {