简体   繁体   English

如何仅针对 Jenkins 管道后期条件指定要在 Kubernetes 集群上执行的容器/代理

[英]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.

相关问题 如何在kubernetes内运行的jenkins管道中运行sidecar容器 - How to run sidecar container in jenkins pipeline running inside kubernetes Jenkins CD管道到Kubernetes - Jenkins CD Pipeline to Kubernetes 在Kubernetes集群中部署Jenkins - Deploy Jenkins in Kubernetes cluster agent{} jenkins 脚本管道中的等效命令,以使用 docker 容器作为从代理 - agent{} equivalent command in jenkins scripted pipeline to use docker container as slave agent 在 docker 容器中运行 jenkins 代理,问题与 jenkins 管道和 /var/run/docker.socket - Run jenkins agent in docker container, issue with jenkins pipeline and /var/run/docker.socket 如何在基于 dockerfile 的容器中运行 Jenkins 管道? - How to run Jenkins pipeline in a container based on a dockerfile? 如果我在代理上手动执行它就可以工作,但如果 Jenkins 将它作为管道的一部分执行它就不行 - Works if I execute it manually on the agent but it doesn't if Jenkins execute it as a part of the pipeline 将 Minikube 集群作为 Jenkins 代理运行 - Running Minikube Cluster as Jenkins Agent 使用 sudo 运行 jenkins 管道代理 - run jenkins pipeline agent with sudo 如何在特定的奴隶中限制jenkins管道码头代理? - How to restrict the jenkins pipeline docker agent in specific slave?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM