It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

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.

2 answers

1 accepted

0 votes
Answer accepted

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.

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.

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..

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.

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?

@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.

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

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
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

375 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you