I am not getting a "Build failed" event in Jira for pipelines with jobs on "push"

I am running a Jira Cloud instance that is integrated with a Gitlab Cloud (SaaS, no paid subscription) repo using the official tools. I have successfully created several automation rules in Jira, so both apps are well configured and connected, but there is one rule that is not working, it is not being triggered

My goal is to detect in Jira when the pipeline fails in order to change the ticket status

My desired flow is

  1. User creates Merge Request
    1.1 Jira detects this event and changes ticket status
    1.2 Pipeline is run for $CI_PIPELINE_SOURCE == 'merge_request_event' jobs
    1.3 Pipeline finishes (uses feature branch)
    1.4 Jira detects failed status and changes ticket status
  2. User merges the MR
    2.1 Jira detects this event and changes ticket status
    2-2 Pipeline is run for $CI_COMMIT_BRANCH == 'main' && $CI_PIPELINE_SOURCE == 'push' jobs
    2.3 Pipeline finishes (uses main branch after the merge)
    2.4 Jira detects failed status and changes ticket status

This flow is working except for the last step. I have created the Jira rule for it but the rule is not being triggered. Since the rule trigger is cloned from the 1.4 rule, I am assuming that the problem is that the integration is failing, Gitlab is not publishing the event

This is my .gitlab-ci.yml file

stages:          # List of stages for jobs, and their order of execution
  - build
  - deploy

build-job:    # This job runs the build stage, which runs on Merge Request creation.
  stage: build
  rules:
    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
  script:
    - echo "Compiling the code..."
    - echo "Compile complete."

deploy-job:   # This job runs the deploy stage, which runs on Merge into Main branch.
  stage: deploy
  rules:
    - if: $CI_COMMIT_BRANCH == 'main' && $CI_PIPELINE_SOURCE == 'push'
  script:
    - echo "Deploying the code..."
    - echo "Deploy complete."
    - fakecommand

That fakecommand is on purpose for forcing the pipeline to fail

It is a public project … tongilcoto-xray / dev-fake-project · GitLab

You can see also the screenshots from Jira rule log dashboard and also how the “log build status” rule is configured


Is it a bug?
Should I modified my pipeline? As you can guess, my goal is to have feedback on the main branch performance after the merge is completed.

1 Like

I have found that the Merge Request has the pipeline check as passed because it only checks the jobs that are executed at “merge_request” event, but the Merge Request has another pipeline failed, the one that is executed at “push” event. Merge Requests: Merge requests · tongilcoto-xray / dev-fake-project · GitLab , Last MR …BAS-3 adding a new rule for logging. MR (!9) · Merge requests · tongilcoto-xray / dev-fake-project · GitLab


If this behaviour is intended, how can I get the result of the pipeline on “push” in Jira?

1 Like