This repo demonstrates how to post back to the GitHub Deployment API from a Jenkins Pipeline. See the Jenkinsfile for the exact Pipeline.
- Create a Multibranch Pipeline (or use GitHub Organization Folders) within Jenkins that references this repository.
- Install the HTTP Request Plugin and the Pipeline Utility Steps on Jenkins.
- Add a branch, make a modification, and create a Pull Request in GitHub.
- Run the pipeline jobs again and you should see the deployment recorded in the Pull Request
The Jenkins pipeline has 2 stages: build and deploy.
- Build Stage:
- Maven command is run to build the project.
- Deploy Stage
- Creates a GitHub Deployment via API using the HTTP Request Plugin
- Saves the deployment id of the deployment just created
- Executes the deployment
- Creates a GitHub Deployment Status based on the outcome of the deployment via API using the HTTP Request Plugin
The project is available as open source under the terms of the MIT License.