Reputation: 321
Through the terminal, it's as simple as source activate MyCondaEnv
, but if I try in a Jenkinsfile:
sh '. /home/rwardrup/anaconda3/bin/activate MyCondaEnv',
The Jenkins console returns:
Running shell script
+ . /home/rwardrup/anaconda3/bin/activate MyCondaEnv
+ [[ -n ]]
/var/lib/jenkins/workspace/testing/features@tmp/durable-bb4a4c30/script.sh: 4: /home/rwardrup/anaconda3/bin/activate: [[: not found
+ [[ -n ]]
/var/lib/jenkins/workspace/testing/features@tmp/durable-bb4a4c30/script.sh: 7: /home/rwardrup/anaconda3/bin/activate: [[: not found
+ echo Only bash and zsh are supported
Only bash and zsh are supported
+ return 1
I've tried throwing a little shebang in there: sh '$!/bin/bash. /home/rwardrup/anaconda3/bin/activate MyCondaEnv'
, thinking that it could have to do with that, and I get:
Running shell script
+ /bin/bash. /home/rwardrup/anaconda3/bin/activate MyCondaEnv
/var/lib/jenkins/workspace/testing/features@tmp/durable-2a550d19/script.sh: 2: /var/lib/jenkins/workspace/testing/features@tmp/durable-2a550d19/script.sh: /bin/bash.: not found
Is there any way to activate and use a Conda environment through a Jenkinsfile? I've found some info on using a Django venv in a Jenkinsfile, but that didn't work in my situation.
Upvotes: 1
Views: 3262
Reputation: 6071
It looks like an incorrect syntax for shebang and a missng newline after.
Try this:
sh '''#!/bin/bash
. /home/rwardrup/anaconda3/bin/activate MyCondaEnv
'''
Upvotes: 5