简体   繁体   English

通过脚本重新触发失败的构建

[英]Retrigger failed build through a script

I have ci job in jenkins which triggers for every change in gerrit it triggers ci build is there any possible way to retrigger through script我在 jenkins 中有 ci 作业,它会触发 gerrit 中的每个更改,它会触发 ci build 是否有任何可能的方法通过脚本重新触发

If you are asking about automatically restarting the build if it fails, you need to first create a post failure section that would run every time your build fails.如果您询问在构建失败时自动重新启动构建,您需要首先创建一个失败post部分,该部分将在每次构建失败时运行。 You then need to use build pointing to the same pipeline so that a new job is scheduled.然后,您需要使用指向同一管道的build ,以便安排新作业。 Something like this:是这样的:

post {
  failure {
    build(job: '<your_job_name>', wait: false)
  }
}

If the job is parameterized, you can pass the parameters from your current job.如果作业已参数化,您可以传递当前作业的参数。 Your current job will then fail and the a new job which basically a duplicate of your recently finished job will have started running.然后,您当前的工作将失败,并且基本上是您最近完成的工作的副本的新工作将开始运行。

On the other hand, if you are asking about ways to trigger a build without using the UI (by using some shell script somewhere for example), then consider using the Remote Access API .另一方面,如果您询问如何在不使用 UI 的情况下触发构建(例如,通过在某处使用一些 shell 脚本),请考虑使用远程访问 API

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM