Use a var to define the agent label.

This commit is contained in:
Manuele Simi 2019-10-04 09:11:36 -04:00
parent 5ea6bcbf7e
commit fd0ee8e267
1 changed files with 4 additions and 3 deletions

7
Jenkinsfile vendored
View File

@ -4,6 +4,7 @@ import org.yaml.snakeyaml.Yaml
def (options, maven_local_repo_path, maven_settings_file) = ['', '', ''] def (options, maven_local_repo_path, maven_settings_file) = ['', '', '']
def maven_jdk = 'OpenJDK 8' def maven_jdk = 'OpenJDK 8'
def agent_root_folder = '/var/lib/jenkins/.m2' def agent_root_folder = '/var/lib/jenkins/.m2'
def agent_label = 'pipeline-agent'
if (params.Type == 'SNAPSHOT-DRY-RUN') { if (params.Type == 'SNAPSHOT-DRY-RUN') {
echo "Configure Maven for SNAPSHOT-DRY-RUN artifacts" echo "Configure Maven for SNAPSHOT-DRY-RUN artifacts"
@ -61,7 +62,7 @@ pipeline {
// see https://jenkins.io/doc/book/pipeline/syntax/#agent // see https://jenkins.io/doc/book/pipeline/syntax/#agent
agent { agent {
label 'pipeline-agent' label agent_label
} }
// see https://jenkins.io/doc/book/pipeline/syntax/#environment // see https://jenkins.io/doc/book/pipeline/syntax/#environment
@ -101,7 +102,7 @@ pipeline {
echo build(job: 'maven-parent', wait: true, echo build(job: 'maven-parent', wait: true,
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"], parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"],
[$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"], [$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"],
[$class: 'LabelParameterValue', name: 'exec_label', label: "pipeline-agent", nodeEligibility: [$class: 'AllNodeEligibility']] [$class: 'LabelParameterValue', name: 'exec_label', label: agent_label, nodeEligibility: [$class: 'AllNodeEligibility']]
]).result ]).result
echo "Done with maven-parent" echo "Done with maven-parent"
} }
@ -189,7 +190,7 @@ def buildComponents(args, maven_settings_file, maven_local_repo_path) {
build(job: name, build(job: name,
parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"], parameters: [[$class: 'StringParameterValue', name: 'gcube_settings', value: "${maven_settings_file}"],
[$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"], [$class: 'StringParameterValue', name: 'local_repo', value: "${maven_local_repo_path}"],
[$class: 'LabelParameterValue', name: 'exec_label', label: "pipeline-agent", nodeEligibility: [$class: 'AllNodeEligibility']] [$class: 'LabelParameterValue', name: 'exec_label', label: agent_label, nodeEligibility: [$class: 'AllNodeEligibility']]
]) ])
} }
] ]