I'm trying to configure an automated pull-request job triggering in a monorepo concluded from several subdirectories. This means I need to run a specific pipeline per subdirectory, and not run unnecessary ones.

What I have already tried:

  1. Github Pull Request Builder plugin - Which is a great plugin for those who are not running a scripted pipeline, but rather a "Classic" Jenkins project. Also, it is no longer supported and many issues remain unanswered there.
  2. Git SCM Jenkins Plugin - which has a promising feature of includedRegions and excludedRegions, and is supposed to trigger jobs based on a regular expression. Unfortunately, it doesn't work as expected and triggers builds on any changes.
  3. Using the Git changeset that Jenkins receives, perform a Validate stage when build starts, and if none of the changed files starts with the required subdirectory - abort and exit the build. This results in tens of aborted unnecessary builds.
  4. Jenkins Generic Webhook Plugin - This plugin is a simple to use plugin that relies on the json payload it receives in a webhook, and triggers a job based on a defined filter. The problem is that in Github's API, pull request opened/updated events do not include the changed files. So this use case only works with Github's "push" event, but not specifically with PR events.

I want the flow to work this way:

  1. A developer opens a pull request in Github. His/hers changes are related to a subdirectory in a monorepo called APP1/.
  2. Jenkins receives a notification (or a webhook of some sort) and triggers a job that builds and tests APP1.
  3. Jenkins sends the build/test result back to the pull request checks view (I've got this stage covered).

0 Answers