This commit is contained in:
Jim Nicholson 2024-02-13 22:57:44 -08:00
parent 5ec93d5a46
commit 32b0b566b3

View File

@ -27,25 +27,32 @@ void call(Map config = [:], Closure body) {
stage(runConfig.stepName) { stage(runConfig.stepName) {
printBanner(runConfig.stepName) printBanner(runConfig.stepName)
if (fileExists(runConfig.venvDir) && runConfig.recreateVenv) { if (fileExists(runConfig.venvDir) && runConfig.recreateVenv) {
echo "Removing old venv..."
dir(runConfig.venvDir) { dir(runConfig.venvDir) {
deleteDir() deleteDir()
} }
} }
if (!fileExists(runConfig.venvDir)) { if (!fileExists(runConfig.venvDir)) {
sh "${runConfig.pythonPath} -m venv ${runConfig.venvDir}" createVenv = "${runConfig.pythonPath} -m venv ${runConfig.venvDir}"
echo "python create venv cmd is: ${createVenv}"
sh "${createVenv}"
} }
withEnv(venvEnv) { withEnv(venvEnv) {
if (runConfig.updatePip) { if (runConfig.updatePip) {
echo "Updating pip..."
sh "${venvPython} -m pip install --upgrade pip" sh "${venvPython} -m pip install --upgrade pip"
} }
if (runConfig.installPipTools) { if (runConfig.installPipTools) {
echo "Installing pip-tools..."
sh "${venvPython} -m pip install pip-tools" sh "${venvPython} -m pip install pip-tools"
} }
if (fileExists(runConfig.requirementsFile)) { if (fileExists(runConfig.requirementsFile)) {
echo "Collecting requirements ..."
sh "pip-compile ${runConfig.requirementsFile}" sh "pip-compile ${runConfig.requirementsFile}"
} }
echo "Executing closure..."
body() body()
} }
} }