-
Bug
-
Resolution: Unresolved
-
Minor
-
atlassian-bitbucket-server-integration:4.0.0
Description
We just performed a Jenkins plugin upgrade where we upgraded this plugin from 3.3.2 to 3.6.0. Many of our teams are using Job DSL to programmatically configure jobs. We have found that there is a breaking change involving the interaction between the projectName field and Bitbucket webhooks. Before the upgrade it seems that it was valid to set the projectName field in the Job DSL to be either the name of the Bitbucket project or the project key/slug. After taking the upgrade it appears using the Bitbucket project name in the Job DSL field no longer sets up the webhook correctly. Looking at the logs it is complaining about a 404 from the REST API, presumably because it is passing the projectName straight through to the REST API instead of converting the field to a project key when processed. This issue is affecting pipeline and multibranch projects. We have not upgraded our instance to 4.0.0 due to another issue that I filed [JENKINS-73502] GIT_BRANCH Variable Now Contains the Remote Name - Jenkins Jira, however I installed 4.0.0 on a test instance and verified the same behavior is broken in the latest veresion of the plugin.
Reproduction Steps
- Create or use an existing Bitbucket project and create a repo.
- Grab the project key and project name.
- Project name can be retrieved from this location in the Bitbucket UI
- Grab the Bitbucket project key from the URL
- Set up two Jenkins Job DSL Seed Job with the following content. Replace values with <> with the appropriate values from your setup. The seed jobs configuration should be identical, but one of the seed jobs should replace the projectName field with the project key and the next one should use the project name field.
pipelineJob("generated-job") { displayName('generated-job') definition{ cpsScmFlowDefinition{ scm{ BbS { id('generated-job') branches { branchSpec { name(<your-branch-here>) } } // REPLACE this value with project key for one job and project name for another projectName(<project-key/project-name>) repositoryName(<your-repository-name-here>) credentialsId(<your-credentials-here>) mirrorName(null) gitTool(null) sshCredentialsId(null) serverId(<your-bitbucket-server-id-here) } } scriptPath(Jenkinsfile) } } properties{ pipelineTriggers{ triggers{ BitbucketWebhookTriggerImpl { // This triggers a build after a pull request is opened, or the source branch of a pull request is updated. pullRequestTrigger(true) // This triggers a build in Bitbucket after every push to the configured repository. refTrigger(true) } } } } }
Example: (
// This Seed job will fail to register the webhook and respond to branch events!
projectName('Jenkins Configuration')
// This seed job will register and function as expected
projectName('JENKINSCONFIG')
Before taking the upgrade using either the project name or project key correctly setup the webhook, now only the project key works. Let me know if you need any more information or clarification.