简体   繁体   English

在 Jenkins 中构建完成后触发相同的 jenkins 作业

[英]Triggering the same jenkins job after the build is finished in Jenkins

Is there a way to trigger the same job when the build is finished.有没有办法在构建完成时触发相同的工作。 I have one job that needed to be run until I aborted it manually.我有一项工作需要运行,直到我手动中止它。 Is there a way to accomplish this?有没有办法做到这一点?

The easiest way to do this is to add a post build step that builds the same project. 最简单的方法是添加构建同一项目的后期构建步骤。 Set "Post-build Actions" - "Build other projects" - "Projects to build" to the name of your project and it will loop forever. 将“构建后操作” - “构建其他项目” - “要构建的项目”设置为项目名称,它将永远循环。

This is a pretty crazy request. 这是一个非常疯狂的请求。 Are you sure that's what you want to do? 你确定那是你想做的吗? If you just want to keep up to date you could just have the job build when the SCM system changes- even down to using the filesystem as an SCM. 如果您只想了解最新信息,那么您可以在SCM系统更改时创建作业 - 甚至可以将文件系统用作SCM。

If you really want to do it though, it is possible. 如果你真的想这样做,那就有可能。 You can't just tell it to trigger itself, but you can use the REST api. 你不能只是告诉它触发它自己,但你可以使用REST api。

Add a shell build step with the line 使用该行添加shell构建步骤

curl -X POST http://localhost:8080/job/Tester/build

and a new job will get scheduled each time you run build. 每次运行构建时,都会安排一个新工作。

There is "Build after other projects are built" under "Build Triggers" in job configuration page in which you can specify which project to build after which project. 在作业配置页面的“构建触发器”下有“构建其他项目后构建”,您可以在其中指定在哪个项目之后构建哪个项目。 So if you want to continuously run a particular job, you can add Project name ie your job name in "Projects to watch" field under "Build after other projects are built" and can run it with options :- Trigger only if build is stable 因此,如果要继续运行特定作业,可以在“构建其他项目后构建”下的“要监视的项目”字段中添加项目名称,即您的作业名称,并可以使用选项运行它: - 仅在构建稳定时触发
Trigger even if the build is unstable 即使构建不稳定也会触发
Trigger even if the build fails 即使构建失败也会触发

you can try你可以试试

  1. add build step to create few files - file per condition set添加构建步骤以创建几个文件 - 每个条件集的文件
  2. add build step Trigger/call builds on other projects with add parameter factories with For every matching file, invoke one build添加构建步骤使用add parameter factories Trigger/call builds on other projects For every matching file, invoke one build
  3. the called project might have input file as a parameter - it would be passed from the parent project from #2.被调用的项目可能有输入文件作为参数——它将从#2 的父项目传递。

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

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