Hello, dear community,
I am using Bitbucket Data Center version 9.4.
My Bitbucket Data Center is directly integrated with my Jira.
Currently, I want to configure it so that when a pull request is created, Bitbucket checks the Jira ticket associated with the pull request, and if that ticket contains information that it is blocked by another issue, Bitbucket will not allow merging the code with the main branch until the blockers are resolved.
At the moment, I have applied the following configuration:
In the settings of my Bitbucket project, under Hooks, I enabled the Push check parameter.
Within the Push check parameter, I enabled:
status in ("In Progress", "Open", "In Review", "Resolved")
AND issue NOT IN linkedIssues($key, "is blocked by")
AND issue NOT IN linkedIssues($key, "blocks")
Unfortunately, my configuration is not working; I can merge a pull request with the main branch even if the Jira ticket has a blocker from another ticket.
Perhaps I am using the wrong query? Or maybe the options for the Push check parameter are not correct for my task?
Please help me figure this out.
UPDATE:
As is the other example that I used in merge checks section while conducting my investigation. This approach is also correct:
issue = "%key" AND status in ("In Progress", "Open", "In Review", "Resolved") AND NOT ( issueFunction in hasLinks("is blocked by") OR issueFunction in hasLinks("blocks") )
But now I've encountered another problem: for reasons unclear to me, the %key value in Bitbucket is interpreted as [FUI-1234]—in other words, it inserts the square brackets, even though I don’t use them anywhere. If I try to extract the key from the branch instead of the commit, the %branch value is extracted as bugfix/FUI-1234. I have tried many issue key regular expressions, for example, (?:./)?([A-Z]+-\d+)(?:/.)? and (?<=^|[a-z]-|[\s\p{Punct}&&[^-]])(?!FUI-)([A-Z][A-Z0-9_]*-\d+)(?![^\W_]), but none of them work. It turns out that Bitbucket simply cannot find the correct ticket in Jira because it is impossible to perform a search in Jira using square brackets.
Hello @Petro Kostiuk ,
currently it is not possible to use the %key keyword in the JQL. You can only use %key to customize the error message.
The problem is that several keys can occur in a check (message, branch,...) and it is therefore not clear which key to use here.
It is simpler with the error message, as all invalid keys that do not correspond to the JQL are simply output here. In this case with the brackets [TEST-1, TEST-2]
The insertion of (issue = “%key” ) is not necessary, as this happens automatically. All issue keys found will extend the configured JQL with an „AND".
issueKey in (TEST-1,TEST-2) and <your jql>
Let's think about it, maybe we can find a way to split it up. In any case, we have created a feature request internally.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.