diff options
author | Matt Rendina <rendinam@users.noreply.github.com> | 2019-05-14 22:22:05 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-14 22:22:05 -0400 |
commit | 0f87f7a69e5a15562983c71360fc14c543ee466c (patch) | |
tree | 812f6a59993ec68e1aebc1ad7531cffedbce875d | |
parent | 3294b7a9db0cdef10ca1e020e10d30cbaa9df623 (diff) | |
download | jscu_refactor-0f87f7a69e5a15562983c71360fc14c543ee466c.tar.gz |
Add in missing `def`s on var assignments to prevent leakage between build configs (#51)1.3.15
* add def to dump_name assignment to test behavior
* Add 'def' safeguards on other vars in stage
-rw-r--r-- | Jenkinsfile | 2 | ||||
-rw-r--r-- | vars/utils.groovy | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/Jenkinsfile b/Jenkinsfile index 7676154..d61fd53 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,4 +1,4 @@ -//@Library('utils@test_yml') _ +//@Library('utils@yml_fix') _ // [skip ci] and [ci skip] have no effect here. diff --git a/vars/utils.groovy b/vars/utils.groovy index 1676841..2843402 100644 --- a/vars/utils.groovy +++ b/vars/utils.groovy @@ -492,7 +492,7 @@ def buildAndTest(config) { // If conda is present, dump the conda environment definition to a file. def conda_exe = '' - local_conda = "${env.WORKSPACE}/miniconda/bin/conda" + def local_conda = "${env.WORKSPACE}/miniconda/bin/conda" system_conda_present = sh(script:"which conda", returnStatus:true) if (system_conda_present == 0) { @@ -501,26 +501,28 @@ def buildAndTest(config) { conda_exe = local_conda } if (conda_exe != '') { - dump_name = "conda_env_dump_${config.name}.txt" + // 'def' _required_ here to prevent use of values from one build + // config leaking into others. + def dump_name = "conda_env_dump_${config.name}.txt" println("About to dump environment: ${dump_name}") sh(script: "${conda_exe} list --explicit > '${dump_name}'") dump_name = "conda_env_dump_${config.name}.yml" println("About to dump environment: ${dump_name}") sh(script: "${conda_exe} env export > '${dump_name}'") - remote_out = sh(script: "git remote -v | head -1", returnStdout: true).trim() - remote_repo = remote_out.tokenize()[1] + def remote_out = sh(script: "git remote -v | head -1", returnStdout: true).trim() + def remote_repo = remote_out.tokenize()[1] commit = sh(script: "git rev-parse HEAD", returnStdout: true).trim() // Remove 'prefix' line as it isn't needed and complicates the // addition of the 'pip' section. sh(script: "sed -i '/prefix/d' '${dump_name}'") - pip_section = sh(script: "grep 'pip:' '${dump_name}'", returnStatus: true) + def pip_section = sh(script: "grep 'pip:' '${dump_name}'", returnStatus: true) if (pip_section != 0) { sh "echo ' - pip:' >> '${dump_name}'" } // Add git+https line in pip section to install the commit // used for the target project of this job. - extra_yml_1 = " - ${remote_repo}@${commit}" + def extra_yml_1 = " - ${remote_repo}@${commit}" sh "echo '${extra_yml_1}' >> '${dump_name}'" // Stash spec file for use on master node. |