How can I generate an empty commit during an MR merge in GitLab to update Jira issue status?

In GitLab CI, how do I capture the merge request branch for main merge and trigger an empty commit to update Jira status using keywords? See sample below:

empty_commit_job:
  stage: update-status
  script:
    - git config user.name "alice.smith"
    - git config user.email "[email protected]"
    - git fetch origin main && git rebase origin/main
    - echo $MR_CURRENT_BRANCH
    - git commit --allow-empty -m "Updates ISSUE-404"
    - git push origin HEAD:feature-update
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

hey, you could use $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME for the branch name & run an empty commit to trigger jira. might need to adjust the push target to match your branch setup. try that if it doesnt work correctly.

In my experience setting up CI pipelines in GitLab, generating an empty commit has proved useful for triggering Jira updates without modifying actual code. I suggest ensuring proper rebase of your branch against the main branch before committing. Utilizing environment variables such as CI_MERGE_REQUEST_SOURCE_BRANCH_NAME adds clarity to which branch is being updated. Additionally, verifying that your branch push target corresponds to the source branch minimizes potential issues, particularly with audit trails. Fine-tuning these details in your configuration often leads to more reliable integration with Jira.