<p>I have a shared yaml file for multiple pipelines and I would like to parameterize the tag of one of the images in the yaml file.</p>
<p>What would be the simplest way to do this? At the moment I am maintaining multiple <code>KubernetesPods.yaml</code>, such as <code>KubernetesPods-1.5.0.yaml</code> and interpolating the parameter into the name ( <code>yamlFile &quot;KubernetesPods-${params.AGENT_POD_SPEC}.yaml&quot;</code>), but this does not scale well.</p>
<p>Can I get parameters into the yaml without having to have the yaml written out in every pipeline?</p>
<p>Example pipeline:</p>
<pre><code>pipeline {
  agent {
    kubernetes {
      yamlFile 'KubernetesPods.yaml'
    }
  }
  parameters {
    choice(
      name: 'AGENT_POD_SPEC',
      choices: ['1.5.0','1.3.0','1.2.0','1.4.0'],
      description: 'Agent pod configuration'
    )
  }
}
</code></pre>
<p>Example KubernetesPods.yaml:</p>
<pre><code>kind: Pod
spec:
  containers:
  - name: example-image
    image: example/image:&lt;IMAGE-TAG-I-WANT-TO-PARAMETERIZE&gt;
    imagePullPolicy: Always
    command:
    - cat
</code></pre>

Thomas Teece
<p>You can do it using <code>yaml</code> instead of <code>yamlFile</code></p>
<pre><code>pipeline {
  agent {
    kubernetes {
      yaml &quot;&quot;&quot;
kind: Pod
spec:
  containers:
  - name: example-image
    image: example/image:${params.AGENT_POD_SPEC}
    imagePullPolicy: Always
    command:
    - cat
&quot;&quot;&quot;
    }
  }
  parameters {
    choice(
      name: 'AGENT_POD_SPEC',
      choices: ['1.5.0','1.3.0','1.2.0','1.4.0'],
      description: 'Agent pod configuration'
    )
  }
}
</code></pre>
