How can you activate a conda environment through a Jenkinsfile?
<p>Through the terminal, it's as simple as <code>source activate MyCondaEnv</code>, but if I try in a Jenkinsfile:</p>

<pre><code>sh '. /home/rwardrup/anaconda3/bin/activate MyCondaEnv',
</code></pre>

<p>The Jenkins console returns:</p>

<pre><code>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
</code></pre>

<p>I've tried throwing a little shebang in there: <code>sh '$!/bin/bash. /home/rwardrup/anaconda3/bin/activate MyCondaEnv'</code>, thinking that it could have to do with that, and I get: </p>

<pre><code>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
</code></pre>

<p>Is there any way to activate and use a Conda environment through a Jenkinsfile? I've found some info on using a <a href="https://stackoverflow.com/questions/38450159/how-can-i-write-a-groovy-jenkinsfile-for-a-django-application-to-run-my-tests">Django venv in a Jenkinsfile</a>, but that didn't work in my situation.</p>