title: How to make credentials available to shell script in jenkins
body: <p>We have freestyle projects configured in Jenkins, running shell scripts as build steps. In some cases we need access to credentials for third-party services. We have solved this by providing the credentials as:</p>
  
  <pre><code>USER=theuser
  PASS=thepass
  </code></pre>
  
  <p>in the project environment (<code>Prepare an environment for the run -&gt; Properties Content</code>)</p>
  
  <p>This is working fine, but it is a bad solution because:</p>
  
  <ul>
  <li>credentials are not stored securely</li>
  <li>they are visible to anybody having access to the project configuration</li>
  <li>they leak in the Jenkins console</li>
  </ul>
  
  <p>We have researched a bit and found a <a href="https://wiki.jenkins-ci.org/display/JENKINS/Credentials+Plugin" rel="noreferrer">promising plugin</a>, but we do not know how to make the credentials managed by the plugin available to our scripts, ideally as environment variables.</p>
  
  <p>How can we access the credentials managed by the Jenkins plugin from a script?</p>