title: Activate conda environment from docker image in Jenkinsfile
body: <p>I'm trying to activate a conda environment in my Jenkinsfile, which was created from a Dockerbuild, but I can't figure out how to activate the environment in the shell script in my Jenkinsfile.</p>
  
  <p>But this line <code>. /opt/conda/envs/myapp-env/bin/activate</code> fails on activating in my Jenkinsfile</p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>FROM continuumio/miniconda3:latest
  
  WORKDIR /tmp/app
  
  COPY environment.yml environment.yml
  
  #missing dependencies
  
  RUN conda config --add channels conda-forge \ 
    &amp;&amp; conda env create -n myapp-env -f environment.yml \
    &amp;&amp; rm -rf /opt/conda/pkgs/*
  
  ENV PATH /opt/conda/envs/myapp-env/bin:$PATH
  
  RUN echo $PATH
  RUN conda env list
  </code></pre>
  
  <p><strong>Jenkinsfile</strong>: </p>
  
  <pre><code>try {
          stage('Activate environment &amp; Unit Test') {
              buildImage.inside {
  
                  sh '''
                  echo $PATH
                  echo $HOME
                  . /opt/conda/envs/myapp-env/bin/activate &amp;&amp; python -m pytest tests --cov ./server --cov-report term-missing --cov-report xml --junitxml=build/results.xml
                  '''
              }
          }
  </code></pre>
  
  <p>Result of echo $PATH and $HOME:</p>
  
  <pre><code>Running shell script
  + echo /opt/conda/envs/dfog-app/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  /opt/conda/envs/myapp-env/bin:/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  + echo /
  </code></pre>