简体   繁体   English

如何通过评论重新触发 Jenkins 多分支管道中的 GitHub PR 构建?

[英]How to retrigger GitHub PR build in Jenkins multibranch pipeline with comment?

I'm evaluating multibranch pipelines.我正在评估多分支管道。 I created a repo, with a jenkinsfile.我用 jenkinsfile 创建了一个 repo。 The branches were detected, builds were triggered on PR.检测到分支,在 PR 上触发构建。

Now I'd like to rebuild on command via a comment on the GitHub PR, I installed the Multibranch Scan Webhook Trigger Plugin and for now set the regex to .* .现在我想通过 GitHub PR 上的评论重建命令,我安装了Multibranch Scan Webhook Trigger Plugin ,现在将正则表达式设置为.*

When commenting, in the jenkins log, I get 2 lines:评论时,在 jenkins 日志中,我得到 2 行:

2019-11-25 16:30:37.128+0000 [id=1503]  INFO    c.i.j.p.m.ComputedFolderWebHookRequestReceiver#doInvoke: Triggering FMS
2019-11-25 16:30:39.712+0000 [id=1587]  INFO    j.b.MultiBranchProject$BranchIndexing#run: FMS #20191125.163037 branch indexing action completed: SUCCESS in 2.5 sec

Great, it seems that the repository was scanned but it doesn't start a new build, I guess because it doesn't detect a modification.太好了,似乎存储库已被扫描,但它没有开始新的构建,我猜是因为它没有检测到修改。

Any idea how to do or if it's actually possible?知道该怎么做或者是否真的有可能吗?

You can trigger a multibranch pipeline build in Jenkins by using the GitHub PR Comment Build Plugin :您可以使用GitHub PR Comment Build Plugin在 Jenkins 中触发多分支管道构建:

This plugin listens for comments on pull requests and will trigger a GitHub multibranch job if a comment body matches the configured value, such as "rerun the build".此插件会侦听拉取请求的评论,如果评论正文与配置的值匹配,则将触发 GitHub 多分支作业,例如“重新运行构建”。 This is implemented as a branch property on multibranch jobs.这是作为多分支作业的分支属性实现的。

To enable this behavior, simply add one or more of the branch properties from this plugin to the multibranch job and configure the regular expression to match against the comment body.要启用此行为,只需将此插件的一个或多个分支属性添加到多分支作业并配置正则表达式以匹配评论正文。 詹金

You also need to configure the GitHub webhook to fire on the Pull Request comment, which it sounds like you've already done.您还需要配置 GitHub webhook 以触发 Pull Request 评论,这听起来您已经完成了。

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

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