I am currently using Jenkins CI with Github webhooks. I set up a view for my Github Organization. Jenkins is able to scan my organization for branches and pull requests and run builds on pull requests with Jenkinsfiles. This current discovery functionality is okay. However, when a new pull request gets opened on a repo, a build is run for both the branch, and the pull request. These are being done in separate workspaces as well. So in github, I see builds for continuous-integration/jenkins/branch
and continuous-integration/jenkins/pr-merge
. I would only like to run the build for the pr-merge and not for branch. I can't seem to find any configuration options in Jenkins to tweak this.
It seems that I am looking for options specified in the Github Branch Source Plugin
in this section. I have confirmed that the plugin is installed, but I can't find a way to modify these settings anywhere, neither in the GUI, nor $JENKINS_HOME
.
Any help on how to do this would be much appreciated. There's really no benefit for us to have a build log of all branches being used for pull requests, since they are later discarded.
Configure your pipelineOn the Datalog Tagging tab, check “GitHub project”, and put your project URL in the field. On the Build Triggers tab, check “GitHub Pull Request Builder”. Then the GitHub API credentials is automatically filled in. Make sure the Admin list is filled in with at least one admin name.
Pull requests let you tell others about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.
If you add Filter by name (with regular expression)
to Behaviours
as develop|PR-.*
it will stop triggering the pipeline for branches that doesn't match the pattern.
screenshot
You can change the Discover branches strategy to exclude branches that are also filed as pull request:
Discover Branches: Exclude branches that are also filed as PRs
See Controlling what is built section on the documentation page for the Github Branch Source plugin page. https://go.cloudbees.com/docs/cloudbees-documentation/cje-user-guide/index.html#github-branch-source
Would also suggest if you have your GitHub repository configured for status checks you disable the branch status' that was generated so your PR only depends on the PR status. See GitHub doc: https://help.github.com/articles/enabling-required-status-checks/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With