diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | vars/conda.groovy | 50 |
2 files changed, 54 insertions, 0 deletions
@@ -1,2 +1,6 @@ # shared_utils Shared utilities for use within Jenkins jobs + +## Provides +`conda.install(version="4.3.31", py_maj_version=3, install_dir="miniconda")` + diff --git a/vars/conda.groovy b/vars/conda.groovy new file mode 100644 index 0000000..8b80dd9 --- /dev/null +++ b/vars/conda.groovy @@ -0,0 +1,50 @@ +// Shared functionality for managing conda installation. + +def install(version="4.3.31", py_maj_version=3, install_dir="miniconda") { + + def CONDA_BASE_URL = "https://repo.continuum.io/miniconda" + def conda_installers = ["Linux-py2":"Miniconda2-${CONDA_INSTALLER_VERSION}-Linux-x86_64.sh", + "Linux-py3":"Miniconda3-${CONDA_INSTALLER_VERSION}-Linux-x86_64.sh", + "MacOSX-py2":"Miniconda2-${CONDA_INSTALLER_VERSION}-MacOSX-x86_64.sh", + "MacOSX-py3":"Miniconda3-${CONDA_INSTALLER_VERSION}-MacOSX-x86_64.sh"] + def OSname = null + def uname = sh(script: "uname", returnStdout: true).trim() + if (uname == "Darwin") { + OSname = "MacOSX" + println("OSname=${OSname}") + } + if (uname == "Linux") { + OSname = uname + println("OSname=${OSname}") + } + assert uname != null + + // Check for the availability of a download tool and then use it + // to get the conda installer. + def dl_cmds = ["curl -OSs", + "wget --no-verbose --server-response --no-check-certificate"] + def dl_cmd = null + def stat1 = 999 + for (cmd in dl_cmds) { + stat1 = sh(script: "which ${cmd.tokenize()[0]}", returnStatus: true) + if( stat1 == 0 ) { + dl_cmd = cmd + break + } + } + if (stat1 != 0) { + println("Could not find a download tool. Unable to proceed.") + return false + } + + def WORKDIR = pwd() + def conda_install_dir = "${WORKDIR}/${install_dir}" + def conda_installer = + conda_installers["${OSname}-py${py_maj_version}"] + dl_cmd = dl_cmd + " ${CONDA_BASE_URL}/${conda_installer}" + sh dl_cmd + + // Install specific version of miniconda + sh "bash ./${conda_installer} -b -p ${conda_install_dir}" + return true +} |