title: Reading Jenkins pipeline configuration files outside workspace
body: <p>I have jenkins pipelines in a git repo called <code>jenkins-pipelines</code>. I have multiple jenkins instances <strong>one per environment</strong>. To keep <strong>a single pipeline for all environments</strong>, I externalized the environment specific variables for each pipeline in a folder called <code>config</code> within <code>jenkins-pipelines</code> git repo.</p>
  <p>Here is a snippet that I use in my k8s pipeline to read the pipeline config. The problem is the pipeline config is not available in project workspace and I have to write the conditional snippet to guess and read the pipeline config file. Is there a better and straight forward way to address this problem?</p>
  <pre><code>     sh '''#!/bin/bash 
            if [ -d 'config' ]; then
              cat config/k8s.json 
            elif [ -d ../workspace@script ]; then
              cat ../workspace@script/config/k8s.json 
            elif [ -d ../${JOB_NAME}@script ]; then
              cat ../${JOB_NAME}@script/config/k8s.json
            fi
       ''' 
  </code></pre>
  <p>Example config in <code>jenkins-pipelines</code> repo k8s/config.json:</p>
  <pre><code>{
    &quot;aws-env1&quot;: {
       &quot;state&quot;: &quot;blah&quot;
    },
    &quot;azure-env1&quot;: {
       &quot;state&quot;: &quot;blah2&quot;
    }
  }
  </code></pre>