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 controller
-
CloudBees CI (CloudBees Core) on traditional platforms - Client controller
-
CloudBees Jenkins Enterprise - Managed controller
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": "https://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": "main", "target": { "type": "commit", "hash": "b7c6fa5e437beb9dba60993f326ea26c4be6eca8" } }, "old": { "type": "branch", "name": "main", "target": { "type": "commit", "hash": "f690661139936373bb0c4a1f2534cc5cfceb0707" } } } ] } }
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" https://JENKINS_URL/bitbucket-hook/ -d @file.json
This article is part of our Knowledge Base and is provided for guidance-based purposes only. The solutions or workarounds described here are not officially supported by CloudBees and may not be applicable in all environments. Use at your own discretion, and test changes in a safe environment before applying them to production systems.