...
Webhook to Jenkins for Bitbucket version 4.2 and higher support sending custom URL job parameters to Jenkins during the notification/trigger process adding them to notified Jenkins URL. To use this feature, you must also configure Jenkins to allow URL parameters.
Info |
---|
The URL parameter Job Parameter feature is only available when using the Git plugin and Direct Job Trigger endpoints. Bitbucket Branch Source plugin is not supported at this time. |
...
Git Plugin for Jenkins version 2.5.0 and higher will by default reject all URL parameters. You must configure Jenkins to allow URL job parameters by doing ONE of the following:
...
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 Job Parameters at the bottom of the dialog.
Enter the URL job 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:
Go to your job, click Configure from the left sidebar and go to the General tab. Select This project is parameterized.
click Add Parameter and select String Parameter
in the Name field, enter the name of the parameter that you used in the Webhook to Jenkins URL Job Parameters field.
For each additional parameter, click Add Parameter, select String Parameter and enter the name of the next parameter.
Click Save.
...