5

I'm evaluating multibranch pipelines. I created a repo, with a jenkinsfile. The branches were detected, builds were triggered on 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 .*.

When commenting, in the jenkins log, I get 2 lines:

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?

Bill DeRose
  • 2,330
  • 3
  • 25
  • 36
David Bensoussan
  • 2,887
  • 2
  • 38
  • 55

1 Answers1

2

You can trigger a multibranch pipeline build in Jenkins by using the GitHub PR Comment Build Plugin:

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". 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. Jenkin

You also need to configure the GitHub webhook to fire on the Pull Request comment, which it sounds like you've already done.

Bill DeRose
  • 2,330
  • 3
  • 25
  • 36
  • Does this works with Jenkins Job DSL?How to use with scripted pipeline?..I would like to retrigger a pipeline job via Pull request comment – kc7 Jul 26 '21 at 10:05