Deploy info not sent to Jira when pipeline run in default branch

Deploy info not sent to Jira when pipeline run in default branch

I am using the Jira integration in Gitlab.com and currently I can see commits, branches and merge requests under the development panel in Jira. But sadly, I’ve not found the way to track deployments that runs for default branch.

My current setup has a total of 5 jobs:

  • 2 jobs run during the merge request event
  • 3 jobs run on the default branch after merge happens

To have a more graphical view, this is how it looks like on the merge request:
image

And this is how it looks on the default branch when a new commit happens:

Also, the view from the merge request shows the deployment to the dev environment as expected, including the Jira keys in the commit messages which should allow the communication between both Gitlab and Jira
image

At this point, I would expect the deployment information to appear but only information about the branch, commits and merge request are there:

Here is the content of the .gitlab-ci.yml used for this example:

image: xxxxxxxxx.dkr.ecr.eu-central-1.amazonaws.com/mycompany:latest

services:
  - docker:18.06.1-dind

stages:
  - "Build test image"
  - tests
  - "Build production image"
  - deploy

build_test_image:
  stage: "Build test image"
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  script:
    - echo "Building test docker image"

pytest:
  stage: tests
  needs: [build_test_image]
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  script:
    - echo "Running tests..."

build_production_image:
  stage: "Build production image"
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - echo "Building and publishing build image..."

deploy_to_dev:
  stage: deploy
  needs: [build_production_image]
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  environment:
    name: development
  script:
    - echo "Deploying to dev"

deploy_to_prod:
  stage: deploy
  needs: [deploy_to_dev]
  environment:
    name: production
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: manual
  script:
    - echo "Deploying to production"

Something interesting is that if I move the deployment job (deploy_to_dev) to be executed in the merge request event instead of the default branch, it will do the deployment information to appear in Jira properly as expected.

deploy_to_dev:
  stage: deploy
  needs: [build_production_image]
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  environment:
    name: development
  script:
    - echo "Deploying to dev"

And the result is the expected:


Am I missing something or this is a bug in the integration between Jira and Gitlab?

Any help is appreciated.

As a workaround I built a custom Python script to communicate with Jira through the available Rest API.