In Jira, when there is a github pull request sometimes Jira knows about it and sometimes not

Todd Empcke July 25, 2019

we use smart commits to tag the commit with the jira issue key.  jira correctly identifies which commits are associated with which issues.

When a pull request is created for the branch containing those commits JIRA displays it (sometimes)

So my question is.  Given two issues, both with commits known by jira, and both with an open PR, why does jira know about one PR but not the other?

what variables affect JIRA's ability to associate the PR with the issue? As it does for some and not others.

This causes warnings in the jira release section for done issues, saying they have not been approved in a PR

My goal is to have JIRA correctly identify the PR's associated with each issue.

3 answers

1 accepted

0 votes
Answer accepted
Todd Empcke October 24, 2019

So I opened a support ticket with Atlassian

The official documentation at the time reads like this:

Pull requestsGitHubDo at least one of the following:
  • Include a commit in the pull request that has the issue key in the commit message. Note, the commit cannot be a merge commit.
  • Include the issue key in the pull request title.
    Ensure that the source branch name includes the issue key.
  • If you create the pull request from the Branches dialog of the Development panel in a Jira issue, the issue key is added automatically.
    For example, if you create a pull request that has "TIS-3" in the title, the TIS-3 issue will automatically transition from 'In Progress' to 'In Review'. If you reopen, decline, or merge the pull request, it will also transition the TIS-3 issue accordingly.

However the first point about including a commit in the PR that has the issue key in the commit message no longer works.  They suggested it was intentionally removed and apologized for failing to update the documentation.

For anyone else searching this however I would like to point out that the 2nd option is the easiest to make work.  All you need to do is put the JIRA issue key in the PR title.

The 3rd one I have not tried, as Jira does not allow you to create a github branch, only a bitbucket branch, so I can only guess that the branch only shows up if you put the issue key in the branch name which I have not tried.  It also seems to sometimes show up after you create a PR with the issue key in the PR title, however by then it is not much help.

parag April 12, 2021

Thank you for sharing this feedback.

IMHO, a PR can deliver 1 or more commits to the target branch. Each commit can potentially address one or more Jira issues. Expecting Jira ID in the PR title is therefore incorrect.

Presuming comma works as a delimiter:

JIRA-1234, JIRA-6789, JIRA-9876 Some text here

isn't a friendly PR title. But expecting those Jira IDs in the PR description is a very valid expectation IMO.

Hoping Atlassian identify the problem and rectify it.

0 votes
Christos Savva March 1, 2024

Hello, here in 2024 am going to revive this thread because we have the same situation.

I am trying to make a PR and transition all issues references on the commit messages related to that PR to a new Status.

The doc pages (Jira Issue keys do not show on Pull Request Jira tab | Bitbucket Cloud | Atlassian Documentation) that were last updated on 2023 still say that

 

When a Pull Request is being created, the Jira issue must be present within any of the following components of the Pull Request -

  • The commits associated with the Pull Request must have the Issue key in the commit message.
  • OR the Pull Request title must contain the Issue key.

 

But testing this it seems that is not working. If the Issue IDs are not listed in the PR title JIRA does not pick them up.

Am not sure what is the best practice here, but I am wondering how to resolve the following scenario.

There are 10 issues that we worked on, and the ticket IDs are referenced in the commit messages.

When we decide to merge dev branch to main branch (production) I want to transition all tickets to DONE.

But this is not possible unless I explicitly list all ticket IDs in the PR title. This is not very practical. What is the solution to this?

 

0 votes
Dave Theodore [Coyote Creek Consulting]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 25, 2019

It's a tough question to answer without looking at a case where it has "failed." In my experience, this doesn't randomly fail.  

Here's how things work. First, you need to associate the commit to a Jira issue.  As you mention, this is done via inserting the Jira issue# (and the exact issue#) in the commit message when the commit is made.  You can also add hashtag commands that can do things like add a comment in Jira, transition the workflow, etc. These actions are called Smart Commits (example when you use the BigBrassBand app.) Simply adding a Jira issue number to a commit is not "smart commit," though.

If your Jira instance is configured to be able to create a branch from within Jira, any commits done to that branch will automagically be connected to the Jira issue without needing to include the Jira issue# every time you commit.

The confusion most often comes in cases where people either don't enter a valid issue#, or they think they don't need to add an issue# because they think they are working on a branch that was created from Jira. You need to be sure to include the correct syntax.  For example, "#JRA-123" is not the same as "JRA-123."  

The integration is dead simple. Jira scrapes the commit messages looking for a valid issue#. Those are always in the format of "KEY-<number>" If people don't include a valid issue#, the association doesn't happen. My guess would be that the ones that fail have some syntactic error or the pull request isn't on the branch that the commit was done on. This has been the most commit cause that I have seen.

Todd Empcke July 26, 2019

Thank you for your reply.

We are not at this time creating branches via JIRA (maybe we should).  So that is not the issue.

The key syntax in the commit messages are correct, else JIRA would not be showing the commits associated with the issues.  So that is not the issue.

The only other thing you said that seems to stand out to me is this:

or the pull request isn't on the branch that the commit was done on

I would have to go back and check to confirm on these issues but this is possible.  Suppose we have one person with several related issues spread over a given sprint.

They my have a general branch for the related topic and create branches from it for each single issue.  As those are completed they may be merged into the general branch and then from the general branch create a PR into the develop branch.  As a result the commits would be associated with the jira issues, but the PR would not?

as a rule we only require a PR when merging your code into someone elses branch or a shared branch..

Dave Theodore [Coyote Creek Consulting]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 26, 2019

I would have a look at where the merge is occurring and see if there are commits on that branch that have a valid Jira issue# in a commit message.  If you can identify a case where there was a) a completed pull request and b) at least one commit on the merging branch with a valid issue# in its commit message, then you can confirm that you have a bug.  If the branch being merged doesn't have a commit with a valid Jira issue# in a commit message, then I wouldn't expect to see the pull request info show up on the Jira issue.

I hope that helps.

Todd Empcke July 31, 2019

Okay, I'm no longer looking at other peoples tasks, commits, branches and PR's .. I just setup a test myself and reproduced the issue

In shell:

  1. git checkout -u todd/fake-branch
  2. echo 'foo' > foo
  3. git add -A
  4. git commit -n -m "CEMS-1324 fake stuff"
  5. git push -u origin todd/fake-branch

on github I created a PR of todd/fake-branch into some other random branch and titled it 'foo bar'

I check Jira issue CEMS-1324 in jira and I can see the commit, but no PR .. also I have a trigger on PR to transition it to awaiting review .. which happens when jira knows about the PR but .. sometimes Jira just does not seem to know about the PR, yet it knows about the commit and there has been no merge of any kind?

Todd Empcke August 7, 2019

@Dave Theodore [Coyote Creek Consulting] given the test results from my previous post I can only conclude that this is a bug?  It is happening often.

Dave Theodore [Coyote Creek Consulting]
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 7, 2019

Could be.  This could also be caused by a network hiccup or something similar.

Todd Empcke October 2, 2019

So this has progressed from always working, to sometimes failing, to hit and miss, to now, almost always failing.

 

JIRA sees commits, but not PR's

 

some months ago I was getting warning messages about having to change how jira and github are linked by a deadline .. if I recall I missed the deadline by a week or so but then I did change it .. I wonder if that has something to do with this.

Suggest an answer

Log in or Sign up to answer