...
Webhook to Jenkins for Bitbucket version 4.2 and higher support sending custom URL parameters to Jenkins during the notification/trigger process. To use this feature, you must also configure Jenkins to allow URL parameters.
Info |
---|
Note The URL parameter feature is only available when using the Git plugin. Bitbucket Branch Source plugin is not supported at this time. |
Table of Contents |
---|
Setup
Configuring Jenkins
Git Plugin for Jenkins version 2.5.0 and higher will by default reject all URL parameters. You must configure Jenkins to allow URL parameters by doing ONE of the following:
...
For detailed instructions on adding Java arguments to Jenkins, see the CloudBees guide.
Usage
Configure Bitbucket Server
Log in to your Bitbucket repository and navigate to Repository Settings > Hooks > Enable or click the Edit setting for Webhooks to Jenkins Server icon.
Click the Advanced Configuration taband locate URL Parameters at the bottom of the dialog.
Enter the URL parameter into the parameter field. The rules for the parameters are as follows:
The formatting for the URL parameter is
DESIRED_VARIABLE_NAME={PARAMETER_NAME}
.Every parameter starts on a new line.
The name given to your parameter is how you reference the parameter in Jenkins. In our example the parameter name is
TARGET_BRANCH
.To pull information from Bitbucket to use as a parameter (like the branch name), refer to the Available parameters section and enter the parameter on the right side of the equal sign surrounded with curly braces
{BRANCH_NAME}
.To use your own custom value, eliminate the curly braces and enter the value to the right of the equal sign.
...
Note |
---|
You cannot use additional parameters together with the Omit SHA1 Hash Code option enabled with Git endpoint. This case is not supported on the Jenkins side. |
Configure Jenkins
To access the parameter in your Jenkins job:
...
Your parameters should now be passed to Jenkins.
...
Available Parameters
To pull information from Bitbucket to use as a parameter (like the branch name), refer to the table below and put the parameter on the right side of the equal sign and surround it with curly braces.
...