title: Jenkins Scripted Pipeline supply GitHub SSH credentials for a 'sh' build step
body: <p>I have a <code>sh</code> step in a scripted Jenkins pipeline that in turn asks git to clone a private GitHub repository via SSH (it's a dependency management system that handles a dependency hosted on GitHub). The pipeline itself is executed via the GitHub Organisation Plugin. It includes a <code>checkout scm</code> command that also accesses a private repository, from the log I see that it makes use of the <code>GIT_SSH</code> environment variable to pass the login-information to that step (that works fine). Is there a way to pass that same information also to another step, i.e. my <code>sh "install_dependencies.sh"</code> step? Note that <code>withCredentials</code> would give me access to the credentials via environment variables, but how do I pass them to git? <code>GIT_SSH</code> is the path to a ssh wrapper script, which I do not know how to generate with <code>withCredentials</code>. Is there another way to pass credentials to git via environment variables?</p>
  
  <p>A minimal <code>Jenkinsfile</code> would look as follows:</p>
  
  <pre><code>node {
      checkout scm  // successfully accesses github credentials
      withCredentials([
          // what to put here?
      ]) {
          // install python dependencies
          sh 'pip install -r requirements.txt'
      }
      sh 'pytest'
  }
  </code></pre>
  
  <p>The file <code>requirements.txt</code> lists dependencies, it contains a line of the form
  <code>
  -e git+ssh://git@github.com/some_private/repo@dev#egg=egg_name
  </code>
  which instructs to <code>pip</code> to fetch the requirement via <code>git</code>.</p>
  
  <p>It is probably possible to manually check-out the code using another Jenkins <code>checkout scm</code> step and then install it from within the Jenkinsfile. However, that would defeat the purpose of having <code>requirements.txt</code> as the single source of truth for requirements.</p>