diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | jenkins/generator_DSL.groovy | 6 | ||||
-rw-r--r-- | jenkins/job-suite-generator.groovy | 50 |
3 files changed, 47 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..783cd5b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.swp + diff --git a/jenkins/generator_DSL.groovy b/jenkins/generator_DSL.groovy index c14efec..4c9c14c 100644 --- a/jenkins/generator_DSL.groovy +++ b/jenkins/generator_DSL.groovy @@ -21,6 +21,12 @@ folder(suite_name) // build jobs. this.script = "dispatch.groovy" + +this.build_control_repo = readFileFromWorkspace("VAR-build_control_repo") +this.build_control_repo = this.build_control_repo.trim() +this.build_control_branch = readFileFromWorkspace("VAR-build_control_branch") +this.build_control_branch= this.build_control_branch.trim() + pipelineJob("${suite_name}/_${script.tokenize(".")[0]}") { // At trigger-time, allow for setting manifest culling behavior. parameters { 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") { } } - |