Configure with Direct Job Trigger

The Direct Job Trigger endpoint allows you to emulate the click of the Build Now button on the Jenkins job page for selected jobs. When the hook event is fired, it has the same effect as clicking this button manually for required jobs.

For example, you can configure the endpoint to build only develop or other baseline branches every time a pull request is merged or when running a staging deployment pipeline for newly pushed tags.

This article provides information regarding configuring Webhook to Jenkins using the Direct Job Trigger endpoint. See the Instances section of the Configure Webhook to Jenkins for Bitbucket Cloud page for additional configuration information.

Configuring Jenkins

This endpoint relies on basic Jenkins functionality and does not require additional plugins. The only required configuration steps are:

  • Configure the job to be built from a Bitbucket repository

  • Build the job with this repository at least once, so it can be found in Jenkins history and mapped to the Bitbucket repository.

Depending on the type of triggered job, it may have different behavior - as per job configuration.

Configuring Bitbucket

To use the Direct Job Trigger endpoint, configure Jenkins credentials for the Webhook to Jenkins app, as you can trigger the job manually only when you are authenticated. See Configuring Credentials page for more information.

Configuring Jenkins instance(s)

  1. Select the repository and when the left sidebar menu opens click Repository Settings .

  2. When the Repository details page opens, scroll down to the bottom of the left sidebar and click Configure Webhook to Jenkins under the Webhook to Jenkins for Bitbucket Cloud heading.

  3. Enable Webhook to Jenkins for this repository.

  4. Enter the URL for your Jenkins instance in the Jenkins URL field. Note that you need to configure this Jenkins instance to use the Direct Job Trigger feature.

  5. Select Direct Job Trigger from the Jenkins Endpoint dropdown.

  6. Type the name of the Jenkins job in Jobs List to see the list of matching jobs for this repository.

  7. Select up to a maximum of five jobs to be triggered by Webhook to Jenkins.

Currently, you can only select freestyle or pipeline jobs that are on the root folder, not jobs that are nested inside folders.

  1. To test your connection, click Test Configuration. When successful, a Connection Succeeded flag appears.

  2. Click Save when finished.

Applying event filters limits events when the trigger fires, while the list of triggered jobs is fixed - those ones you have selected in the Jobs List field.

Additionally, if the Branch Options exclusion filter is configured, matching jobs from those selected are also excluded and are not triggered.