<p>I want to run the post part of my declarative pipeline inside a container which needs to execute on a kubernetes pod using a specific docker image. And I don't know how to set the agent only for post. I'm executing a specific python script which sends an email in the post condition and to execute the script I need python and pip installed on the agent, my docker image has these pre-requites but I don't know how to create an agent with this docker image in the post step. can anyone help me?</p>
<p>Sample of my pipeline</p>
<pre><code>post {
failure {
  echo &quot;job failed&quot;
}
success {
  echo &quot;job succeeded&quot;
}
always {
  node(null) {
    #Python script call to send email
  }
}
</code></pre>
<p>}</p>

Jose
<p>You can setup a Pod as follows for the post step using the Jenkins Kubernetes plugin.</p>
<pre><code> podTemplate(yaml: yamlfile, cloud: cloudName){
    node(POD_LABEL) {
      container(containerName) {
        //steps to perform
      }
    }
</code></pre>
<p>More info on how to use the podTemplate at this link:
<a href="https://www.jenkins.io/doc/pipeline/steps/kubernetes/" rel="nofollow noreferrer">https://www.jenkins.io/doc/pipeline/steps/kubernetes/</a></p>
