-
Bug
-
Resolution: Fixed
-
Minor
-
Jenkins 2.319.1
Bitbucket Server Integration 3.1.0
-
-
3.2.1
I have a multibranch project using the Bitbucket Server Integration plugin. One of the branches is named "bugfix/docfx-improve-this-doc".
On the Jenkins controller, the web page "https://jenkins-REDACTED/jenkins/job/REDACTED/job/REDACTED/job/bugfix%252Fdocfx-improve-this-doc/" displays:
Pipeline bugfix/docfx-improve-this-doc
Full project name: REDACTED/REDACTED/bugfix%2Fdocfx-improve-this-doc
i.e. the Git branch name "bugfix/docfx-improve-this-doc" is encoded as "bugfix%2Fdocfx-improve-this-doc" in the Jenkins job name, and this is further encoded as "bugfix%252Fdocfx-improve-this-doc" in the Jenkins project URL. A bit verbose but OK so far.
The sidebar of this Jenkins web page also has a link "View Branch" pointing to "https://bitbucket.REDACTED/projects/REDACTED/repos/REDACTED/compare/commits?sourceBranch=refs%2Fheads%2Fbugfix%252Fdocfx-improve-this-doc". This is wrong and leads to a Bitbucket Server page saying "'bugfix%2Fdocfx-improve-this-doc' may have been deleted or renamed. Please choose a new source." The link should instead be "https://bitbucket.REDACTED/projects/REDACTED/repos/REDACTED/compare/commits?sourceBranch=refs%2Fheads%2Fbugfix%2Fdocfx-improve-this-doc", i.e. using just %2F rather than %252F.
The bug seems to be that BitbucketJobLinkActionFactory.createFor(Job target) calls externalLinkUtils.createBranchDiffLink(scmRepository, target.getName()), where target.getName() returns the Jenkins job name "bugfix%2Fdocfx-improve-this-doc" rather than the Git branch name "bugfix/docfx-improve-this-doc".
I think this should instead call SCMHead.HeadByItem.findHead(Item item) to get an SCMHead, and then call SCMHead.getName() to get the branch name. That way, it would not assume any relation between Git branch names and Jenkins job names.
(After the 3.1.0 release, BitbucketJobLinkActionFactory has been edited to fix JENKINS-67199, but the target.getName() call is still there.)