Integrating Jenkins with Mergify
How to automate your Jenkins workflow using Mergify
Jenkins is a popular open-source automation server that allows you to build, deploy, and automate your projects. Mergify can interact with Jenkins by evaluating the status checks reported by Jenkins to GitHub. This enables powerful automation workflows that react to the results of your Jenkins jobs.
Prerequisites
Section titled PrerequisitesBefore you can use Mergify with Jenkins, ensure the following:
-
Jenkins is properly set up and is building your projects. See the Jenkins Documentation for help with setting up Jenkins.
-
Jenkins is configured to report build statuses to GitHub. This is typically done via plugins such as the GitHub plugin or the GitHub Branch Source Plugin.
-
The Mergify GitHub App is installed in your repository.
Using Jenkins Status Checks in Mergify Configuration
Section titled Using Jenkins Status Checks in Mergify ConfigurationOnce Jenkins reports status checks to GitHub, they can be used as conditions in your Mergify rules. Here’s a simple example:
pull_request_rules:
- name: Automatically merge when Jenkins build succeeds
conditions:
- check-success = continuous-integration/jenkins/pr-merge # Change this to match your Jenkins check name
- "#approved-reviews-by >= 1"
actions:
merge:
method: merge
In this example, Mergify will automatically merge pull requests that have at least one approved review and a successful Jenkins build.
Further Configuration
Section titled Further ConfigurationThe possibilities of integrating Jenkins with Mergify are extensive. For instance, you could use Mergify to:
-
Automatically update a PR when a build fails;
-
Apply labels, request reviewers, or post comments based on the results of status checks.
We encourage you to explore Mergify’s conditions and actions to create your personalized workflow.