Issue
Webhook troubleshooting is difficult when you don’t know if the issue is with the webhook (on the SCM side) or an issue with Jenkins. Use curl to generate a synthetic (fake) webhook to validate webhook reception on Jenkins.
Environment
- CloudBees CI (CloudBees Core) on modern cloud platforms - Managed Master
- CloudBees CI (CloudBees Core) on traditional platforms - Client Master
- CloudBees Jenkins Enterprise - Managed Master
- CloudBees Jenkins Platform - Client Master
- CloudBees Jenkins Distribution
- Jenkins LTS
- Bitbucket Plugin
- Bitbucket Server Web Post Hooks Plugin
Resolution
Bitbucket Server (from Post-webhook addon)
- Simple push webhook payload
{
"actor": {
"username": "myusername",
"displayName": "My User Name",
"emailAddress": "myuser@cloudbees.com"
},
"repository": {
"scmId": "git",
"project": {
"key": "WEB",
"name": "webhook"
},
"slug": "simple-java-maven-app",
"links": {
"self": [
{
"href": "http://localhost:7990/projects/WEB/repos/simple-java-maven-app/browse"
}
]
},
"ownerName": "WEB",
"public": false,
"fullName": "WEB/simple-java-maven-app",
"owner": {
"username": "WEB",
"displayName": "WEB",
"emailAddress": null
}
},
"push": {
"changes": [
{
"created": false,
"closed": false,
"new": {
"type": "branch",
"name": "master",
"target": {
"type": "commit",
"hash": "b7c6fa5e437beb9dba60993f326ea26c4be6eca8"
}
},
"old": {
"type": "branch",
"name": "master",
"target": {
"type": "commit",
"hash": "f690661139936373bb0c4a1f2534cc5cfceb0707"
}
}
}
]
}
}
Note: The commit hashes don’t matter because we are only validating a push event with Jenkins logs
- Copy json above and replace fields and save it as
file.json
- Run curl
curl -X POST -H "X-Event-Key: repo:push" -H "X-Bitbucket-Type: server" -H "Content-Type: application/json; charset=UTF-8" http://JENKINS_URL/bitbucket-hook/ -d @file.json
Expected Output
2020-12-20 00:42:22.943+0000 [id=1198] INFO c.c.j.p.BitbucketPayloadProcessor#processPayload: Processing new Cloud Webhooks payload
2020-12-20 00:42:22.944+0000 [id=1198] INFO c.c.j.plugins.BitbucketJobProbe#triggerMatchingJobs: Triggering BitBucket job free
0 Comments