diff options
author | Matt Rendina <rendinam@users.noreply.github.com> | 2019-05-07 15:34:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-07 15:34:00 -0400 |
commit | 61fdd601b48119d4e18329dd3d2c290f69ef2850 (patch) | |
tree | 9be05dc5a6fb0f7d2180a953889d09fbea4f3fe9 /vars | |
parent | dc7160a449cd98b7e5ed368746313358cc3ff2a8 (diff) | |
download | jscu_refactor-61fdd601b48119d4e18329dd3d2c290f69ef2850.tar.gz |
Dump YAML version of conda environment (#48)1.3.13
* Dump a YAML file describing the environment used in the job.
* Adjust git rev-parse call to maintain compatibility with very old git.
Diffstat (limited to 'vars')
-rw-r--r-- | vars/utils.groovy | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/vars/utils.groovy b/vars/utils.groovy index 4081980..b38d362 100644 --- a/vars/utils.groovy +++ b/vars/utils.groovy @@ -501,11 +501,32 @@ def buildAndTest(config) { conda_exe = local_conda } if (conda_exe != '') { - println("About to dump environment: 'conda_env_dump_${config.name}.txt'") - sh(script: "${conda_exe} list --explicit > 'conda_env_dump_${config.name}.txt'") + 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] + 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) + 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}" + sh "echo '${extra_yml_1}' >> ${dump_name}" // Stash spec file for use on master node. - stash includes: '**/conda_env_dump*', name: "conda_env_dump_${config.name}", useDefaultExcludes: false + stash includes: '**/conda_env_dump*', + name: "conda_env_dump_${config.name}", + useDefaultExcludes: false } } // end withEnv |