Closed ryanbuhl-auro closed 5 years ago
Can you show me how you're using it? This may well be a bug on my side, but I want to get a better understanding of it
Note: One thing I've noticed is that this doesn't happen for newly created jobs, so I've also now added an explicit cleanWs
call to our pipeline and that seems to have fixed the issue I was seeing with failing build jobs.
Background:
In Jenkins, we have set a Python installation named Python3.7
under the Global Tool Configuration. To avoid the issue caused by pypa/virtualenv#596
, we are creating a custom workspace in our pipeline. We have a defined a shared Groovy snippet which we provide a command we want executed in the virtual environment:
LinkedHashMap<String, Object> call(String cmd){
try{
runCmd = cmd
println "CMD: ${cmd}"
// Use python instance by name from Jenkins Global Tool Configuration
withPythonEnv('Python3.7'){
exitCode = sh (
script: runCmd,
returnStatus: true
)
}
println "CMD run result ${exitCode}"
resultStatus = exitCode == 0 ? 'SUCCESS': 'FAILURE'
return [status: resultStatus, exitCode: exitCode]
}
catch(Exception e){
println "ERROR: ${e.message}"
}
println "shell complete"
}
return this
An example of how we call this snippet is:
shellWithResult('''python3.7 -m pip freeze
python3.7 -m pip install twine coverage pylint_runner pytest
python3.7 -m pip freeze
''')
Hope this helps.
Looking back at it, this is pretty clearly caused by a silly mistake in my code. I'll be fixing and releasing a new version shortly
After updating the Pyenv Pipeline plugin to 2.1.1-STAGING this morning, builds have been failing to install requirements with permissions issues which I wasn't seeing before.
I noticed that the location being created for the virtual env is now being printed to the Jenkins logs, however the location doesn't look correct.
This is an example from the log:
Creating virtualenv at /var/lib/jenkins/workspace/test-lib-dev-216//.pyenv-Python3.7 using Python installation found at /usr/bin/python3.7
Notice that the path contains an extra
/
character before the name of the virtual environment.I don't know if this is an issue with the plugin, or the way I'm using/configuring it.