[英]How to specify a container / agent to execute on Kubernetes cluster for Jenkins pipeline post condition only
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.我想在需要使用特定 docker 映像在 kubernetes pod 上执行的容器内运行我的声明性管道的 post 部分。 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.我正在执行一个特定的 python 脚本,它在 post 条件下发送电子邮件并执行脚本我需要在代理上安装 python 和 pip,我的 docker 映像有这些先决条件,但我不知道如何创建代理在后期步骤中使用此泊坞窗图像。 can anyone help me?谁能帮我?
Sample of my pipeline我的管道示例
post {
failure {
echo "job failed"
}
success {
echo "job succeeded"
}
always {
node(null) {
#Python script call to send email
}
}
} }
You can setup a Pod as follows for the post step using the Jenkins Kubernetes plugin.您可以使用 Jenkins Kubernetes 插件为 post 步骤设置一个 Pod,如下所示。
podTemplate(yaml: yamlfile, cloud: cloudName){
node(POD_LABEL) {
container(containerName) {
//steps to perform
}
}
More info on how to use the podTemplate at this link: https://www.jenkins.io/doc/pipeline/steps/kubernetes/有关如何在此链接中使用 podTemplate 的更多信息: https ://www.jenkins.io/doc/pipeline/steps/kubernetes/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.