OS: Linux - 4.14.209-160.335.amzn2.x86_64
Currently, when a GitHub webhook is used to trigger builds, pushes to any branch will result in the job triggering.
While a branch specifier limits which branch is built, there seems to be two issues:
- It seems that you cannot avoid the initial build of the branch
- There seems to be issues with change detection where a branch is always seen as "changed". This is particularly problematic with ephemeral workspaces (k8s pods) and wildcard branch specifiers.
- When specifying a wildcard branch specifier, all matching branches are built. Combined with the change detection issue, this can result in repeated branch builds with no changes
This behavior can be confusing and result in unexpected behavior as seen in JENKINS-42161.
A seemingly simple solution would be to add branch filtering similar to what is available with the Gitlab plugin.
Branch filtering would ensure that the job is only triggered for intended branches when there are actual events on that branch and would avoid the first build problem.