Jenkins job does not trigger

If the Jenkins job does not trigger, start by checking the logfile for any exceptions.

Next, ensure everything is working correctly, confirm the following points:

  • Polling SCM is enabled (no schedule is necessary, so that field can be left empty) Refer to Git plugin for instructions.

  • Check the configured SCM URLs; they need to be identical.

  • Trigger manually the notification (Test Configuration) from any Webhook to Jenkins for Bitbucket Server tab.

If unsuccessful, trigger the poll manually with curl or similar tools:

curl -v http://<Jenkins URL>/git/notifyCommit?url=<SCM URL>

curl http://jenkins.com:8080/git/notifyCommit?url=ssh://git@bitbucket.com:7999/eee/repo.git

If the Jenkins job does not trigger, there is likely a problem with Jenkins.
If it works, check if all hook files are executable /data/repositories//hooks and /data/repositories//hooks/post-receive.d.

If it still does not work, Enable the debug output and attempt to get some debug information.

Enable the debug output

There are two methods to enable the debug output: activate the general debug output or one of the necessary classes:

General debug

curl \ -u admin -v -X PUT -d "" \ -H "Content-Type: application/json" \ <Bitbucket URL>/rest/api/latest/logs/rootLogger/debug

Debug just the Notification class

curl \ -u admin -v -X PUT -d "" \ -H "Content-Type: application/json" \ <Bitbucket URL>/rest/api/latest/logs/logger/com.nerdwin15.stash.webhook.Notifier/debug

Debug just the test class for Jenkins settings

curl \ -u admin -v -X PUT -d "" \ -H "Content-Type: application/json" \ <Bitbucket URL>/rest/api/latest/logs/logger/com.nerdwin15.stash.webhook.rest.JenkinsResource/debug

This allows you to gather additional information regarding  Bitbucket or the plugin.
To disable the debug output, restart your Bitbucket or run the following commands:

Debugging at the Jenkins side

This plugin sends requests to Jenkins via the Jenkin Git Plugin URL http://<Jenkins URL>/git/notifyCommit?url=<SCM URL>. Trace this request from TCP to Jenkins.

Examining TCP packets

To see the TCP packets sent to Jenkins, use tcpdump:

The tcpdump command displays a lot of data, but you are looking for something like this:

Using the Jenkins logger

Jenkins has built-in logging capabilities. You can create a logger and see what Jenkins receives:

  1. Go to http://jenkins/log/new

  2. Set the name of the new log recorder: git

  3. Click OK.

  4. Add a Logger: hudson.plugins.git

  5. Click Save.

Click Trigger Build to trigger a build from Bitbucket. Go to the logger page (http://jenkins/log/git) and reload the page. You should now see what the Jenkins Git Plugin received. It should look like this:

Received notification for uri = <SCM URL> ; sha1 = <SHA1> ; branches = <BRANCH_NAME>

Examining the Git Polling Log

You can also examine the Git Polling Log on the Job configuration page. The Git Plugin only polls the repository if the URL and the branch match one of the jobs' configurations (all jobs using the Git Plugin are allowed to poll if they match the request sent by Bitbucket).

Â