Jira integration plugin does not recognise branch name

hi
I’m using the latest Jira integration plugin and my goal is to send deployment information to Jira.
I’m using jenkins’ checkout scm pipeline step to check out the code from Bitbucket, however, the debug message says:
[ATLASSIAN CLOUD PLUGIN] [DEBUG] Checking for issue keys for this build …
[ATLASSIAN CLOUD PLUGIN] [DEBUG] Not extracting issue keys from scmRevision.getHead() because it’s not set
[ATLASSIAN CLOUD PLUGIN] [DEBUG] Not extracting issue keys from environment variable CHANGE_BRANCH because it’s not set
[ATLASSIAN CLOUD PLUGIN] [DEBUG] Extracted the following issue keys out of branch name:
[ATLASSIAN CLOUD PLUGIN] [DEBUG] No issue keys could be extracted from this build yet, not sending build event to Jira (yet).

I even tried to inject CHANGE_BRANCH env. variable with EnvInject plugin, it’s visible in printenv but did not helped.

The issue keys are extracted from the commit messages, but the branch ->issue pairing does not work
any help is appreciated!

Hello @tamaszsellerp92 and welcome to this community :wave:

It looks like the Atlassian Cloud Plugin doesn’t give you the result you were expecting.

As you mentioned, issue keys are typically extracted from commit messages. I think that in your example your commit messages does not contain valid Jira issue keys, right? The format for Jira issue keys is typically two or more uppercase letters, followed by a hyphen, and then the issue number (e.g., ABC-123).
If issue keys are not found in commit messages, the plugin may try to extract them from branch names. I can’t tell from your log if this is the case, I just see a square as your branch name. :thinking:
Please make sure that your branch names follow a consistent naming convention that includes issue keys if you’re expecting them here.

Thanks Bruno!
yes, the commit messages and the branch names both contain the issue names.
from the commit messages it can extract them correctly, only the branch names are not working.
the CHANGE_BRANCH env variable is empty when checking with printenv

1 Like

do you maybe know any way to debug this?
eg print the value of CHANGE_BRANCH env or the scmRevision.getHEad() value?

1 Like

Branch API sets the CHANGE_BRANCH environment variable if it is building a pull request, not when it is building a branch. This normally requires a multibranch project with pull request discovery enabled. Make sure the multibranch project has a compatible branch source:

  • A “Git” branch source (from the Git plugin) does not support pull request discovery, so CHANGE_BRANCH is never set.
  • A “Bitbucket” branch source (from the Bitbucket Branch Source plugin) supports pull request discovery and should work with Bitbucket Cloud, Server, or Data Center.
  • A “Bitbucket server” branch source (from the Bitbucket Server Integration plugin) supports pull request discovery (that feature was recently added) and should work with Bitbucket Server or Data Center, but not Bitbucket Cloud.
1 Like

hi KOn
thanks for your answer.
we currently have the pipelines ready and I think I don’t need the PR discovery right now, just want to set the branch name somehow.

The Atlassian Jira Software Cloud plugin source code has a comment saying that it finds the branch name only in “Multibranch Pipeline jobs”:

https://github.com/jenkinsci/atlassian-jira-software-cloud-plugin/blob/ccd3bea4635d66cf7b244011b5ef519491e72c75/src/main/java/com/atlassian/jira/cloud/jenkins/util/BranchNameIssueKeyExtractor.java#L27-L29

Is that the kind of project you are using?