Use SSH Key from Jenkins Git Plugin to Run Git Commands During Build
<p>Our build job on Jenkins runs as part of a release build some git commands like git push and git pull, therefore requires a way to run authenticated git commands from the shell during the build.</p>

<p>Our jenkins slaves don't hold any credentials as they are disposable docker containers that are created per build.</p>

<p>The git plugin manages this with the Jenkins credentials and "somehow" sets GIT_SSH to pick up a private key that is configured via the credentials.</p>

<p>I checked the source code and tried to determine how I can get the variable configured so that I can run for example git pull as an SSH script as part of the build. Without success.</p>

<p>Is there a way to run a git command as part of the build steps using the Jenkins credentials?</p>

<p>My current solution is to copy the SSH key to the slave as part of the build environment setup but seems like duplicate work (plus potential security issue).</p>