aboutsummaryrefslogtreecommitdiff
path: root/jenkins/job-suite-generator.groovy
diff options
context:
space:
mode:
authorMatt Rendina <rendinam@users.noreply.github.com>2017-06-08 20:24:26 -0400
committerGitHub <noreply@github.com>2017-06-08 20:24:26 -0400
commiteb16bc4d7aeb00e77e8c1f130243bac1fb9b55fa (patch)
tree83d62caae69e2e26f2260a307fd3d29ac5397c19 /jenkins/job-suite-generator.groovy
parent370d42fbfb7b6949c5a7d57ba13c6ae34c0f5b42 (diff)
parent900319c12d8e4280926767efea9f18d4256c0d7c (diff)
downloadbuild_control-eb16bc4d7aeb00e77e8c1f130243bac1fb9b55fa.tar.gz
Merge pull request #15 from rendinam/repospec
Simplify control repo and branch specification
Diffstat (limited to 'jenkins/job-suite-generator.groovy')
-rw-r--r--jenkins/job-suite-generator.groovy50
1 files changed, 39 insertions, 11 deletions
diff --git a/jenkins/job-suite-generator.groovy b/jenkins/job-suite-generator.groovy
index cdcb602..7f58297 100644
--- a/jenkins/job-suite-generator.groovy
+++ b/jenkins/job-suite-generator.groovy
@@ -7,6 +7,9 @@
// groovy classpath definition prior to imports.
this.ldir = "libs"
+// URL for the YAML support library used for accessing manifest files
+yURL = "https://repo1.maven.org/maven2/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar"
+
// DSL script path within the repository obtained for this job.
this.dsl_script = "jenkins/generator_DSL.groovy"
@@ -17,19 +20,44 @@ node("master") {
// Delete any existing job workspace directory contents.
deleteDir()
- // These variables are provided by the execution of the generator
- // build task with parameters. Each var is populated by a parameter
- // specification.
- println("manifest_file: ${this.manifest_file}\n" +
+ // Get the git repo and branch values used to obtain this and other
+ // build_control scripts so they may be passed to the jobDSL script
+ // that gets invoked at the bottom of this script. Vars harvested from
+ // the gitSCM stage get written to disk here so that the jobDSL script
+ // below can access them.
+ // Overriding an existing parameter value does not propagate the new
+ // value to the jobDSL script.
+
+ // Both 'scm.getUserRemoteConfigs' and 'getUrl' require script approval
+ build_control_repo= scm.getUserRemoteConfigs()[0].getUrl()
+ sh "echo ${build_control_repo} > VAR-build_control_repo"
+
+ // Get branch spec component after last '/' character.
+ // Branch names themselves shall not have slashes in them
+ // when specified in the job-suite-generator job configuration.
+ build_control_branch = scm.branches[0].toString().tokenize("/")[-1]
+ sh "echo ${build_control_branch} > VAR-build_control_branch"
+
+ // 'Parameters' variables are provided by the execution of the
+ // generator build task with parameters. Each is populated by a
+ // parameter specification at job execution time. Varaiables defined as
+ // build parameters for this job are automatically available in the
+ // called JobDSL script invoked below by using their base name, i.e.
+ // the name here without a 'this.' prefix. Other variables are not
+ // automatically available, see above.
+ println(" From job config:\n" +
+ "build_control_repo: ${build_control_repo}\n" +
+ "build_control_branch: ${build_control_branch}\n" +
+ " Parameters:\n" +
+ "manifest_file: ${this.manifest_file}\n" +
"label: ${this.label}\n" +
"py_version: ${this.py_version}\n" +
- "build_control_repo: ${this.build_control_repo}\n" +
- "build_control_branch: ${this.build_control_branch}\n" +
"conda_version: ${this.conda_version}\n" +
"conda_build_version: ${this.conda_build_version}\n" +
"conda_base_URL: ${this.conda_base_URL}\n" +
"utils_repo: ${this.utils_repo}\n" +
"old_jobs_action: ${this.old_jobs_action}\n" +
+ " Other values:\n" +
"dsl_script: ${this.dsl_script}")
}
@@ -37,11 +65,12 @@ node("master") {
sh "mkdir -p ${this.ldir}"
// Obtain libraries to facilitate job generation tasks.
dir ("libs") {
- sh "curl -O https://repo1.maven.org/maven2/org/yaml/snakeyaml/1.17/snakeyaml-1.17.jar"
+ sh "curl -O ${yURL}"
}
- // Copy files from the implicit checkout of the build_control directory (handled by
- // the job that reads this pipeline script) into the actual workspace of this job so
- // the jobDsl call below will be able to find what it needs.
+ // Copy files from the implicit checkout of the build_control directory
+ // (handled by the job that reads this pipeline script) into the actual
+ // workspace of this job so the jobDsl call below will be able to find
+ // what it needs.
sh "cp -r ${env.WORKSPACE}@script/* ."
}
@@ -53,4 +82,3 @@ node("master") {
}
}
-