Jira Integration - Codemagic Docs
Maybe your like
How to integrate your workflows with Jira using codemagic.yaml
Jira is an issue tracking and project management product developed by Atlassian. Many software development teams use it to maintain the visibility of their projects.
It offers a REST API that can be used in conjunction with your Codemagic workflows to add comments, upload attachments, or transition the status of an issue, story, or epic.
Note: You can find a complete example project showcasing Jira integration in our Sample projects repository.Configure environment variables
To get started, you will need a Jira account (you can sign up for free) and a Jira API Token.
There are four environment variables that need to be configured for the Jira integration: JIRA_AUTH, JIRA_BASE_URL, JIRA_ISSUE and JIRA_TRANSITION_ID. To add a variable, follow these steps:
- Open your Codemagic app settings, and go to the Environment variables tab.
- Enter the desired Variable name, e.g. JIRA_AUTH.
- Enter the required value as Variable value.
- Enter the variable group name, e.g. jira_credentials. Click the button to create the group.
- Make sure the Secret option is selected.
- Click the Add button to add the variable.
- Repeat the process to add all of the required variables.
JIRA_AUTH environment variable
The JIRA_AUTH environment variable is a base64 encoded string which consists of the email address you log into Jira with and the Jira API token you created:
[email protected]:<api_token>
You can encode these credentials in the macOS Terminal using:
echo -n '[email protected]:<api_token>' | openssl base64Alternatively, use an online tool to base64 encode this string.
This value is used in the Authorization header used in cURL requests to the Jira API.
JIRA_BASE_URL environment variable
This is the subdomain you chose when you set up your Jira account e.g. “YOUR_SUBDOMAIN.atlassian.net”. Put the subdomain including “atlassian.net” in the JIRA_BASE_URL environment variable.
JIRA_ISSUE environment variable
Issues, epics, and stories have a unique id, usually in the format ‘projectKey-id’, and is visible on your issues either in the bottom right or top left when looking at an issue. Put this value in the JIRA_ISSUE environment variable.
JIRA_TRANSITION_ID environment variable
If you want to transition your issue to another status, you will need to know what transition ids are available. You can obtain the available transition ids using a cURL request as documented in the Jira API documentation. Once you know the transition id then put this value in the JIRA_TRANSITION_ID environment variable.
Adding formatted comments to a Jira issue
Create a .templates folder in the root of your project. In this folder, create a template file called jira.json, which adds formatted comments to a Jira issue. An example jira.json file can be found in our Sample project.
The Atlassian Document Format (ADF) is used to format the comment layout and style. Click here for more information about ADF and how to modify this template.

Note that it contains strings beginning with $, which the scripts use to replace values in the JSON using sed before it is added as JSON payload to the cURL requests.
Publishing to Jira
Publishing to Jira is performed by a script in the publishing: section in the codemagic.yaml. The example script shown below contains several actions which set environment variables, update the comment template, and then use cURL requests to add a comment and upload files to a specific Jira issue.
Using jq to parse $CM_ARTIFACT_LINKS
First, it uses jq (a command-line tool for parsing JSON) to parse the contents of the Codemagic built-in environment variable $CM_ARTIFACT_LINKS to find information such as the artifact URL, filename, bundle id, and version name and store the values in environment variables.
See this link about the JSON data that $CM_ARTIFACT_LINKS contains.
Setting additional environment variables
Additional environment variables are then set, such as the build number, build date, and commit number. These environment variables are used to replace values in the jira.json comment template using sed, a stream editor for parsing and transforming text.
Making cURL requests to the Jira API
- The script performs a request to add a comment to the Jira issue specified using the jira.json as the payload.
- Another request is used to transition the issue to a different status.
- The script checks to see if XML test results have been generated. See here for information about using test_report to generate a test report .xml output. If xml test results are available, then they will be uploaded to the Jira issue.
- If release notes have been created, then these are uploaded to the Jira issue.
- Configure environment variables
- Adding formatted comments to a Jira issue
- Publishing to Jira
- Using jq to parse $CM_ARTIFACT_LINKS
- Setting additional environment variables
- Making cURL requests to the Jira API
Getting help and support
If you have a technical question or need help with some particular issue, you can get help in our GitHub Discussions community here.
Alternatively, join the Codemagic Community Discord Server here.
If you're a paying customer, use the in-app chat widget to get support. You have to be logged in to see the chat icon at the bottom right corner (please note that some ad blockers might block the chat widget).
Tag » Code Section In Jira Comment
-
Text Formatting Notation Help - Create And Track ... - Jira Atlassian
-
Advanced Formatting - Jira Atlassian
-
Jira Code Formatting: A Few Quick Tips - Valiantys - Atlassian Platinum ...
-
How Do You Add Code Blocks In Jira? - Capiche
-
How Can I Format A Code Block In Jira Without The Markdown Plugin?
-
How Using Markup In Jira Comments Will Transform Your Issues
-
How Do You Get Inline Code/text Highlighting Within A Jira Ticket?
-
How To Insert Code Snippet In Jira Ticket | How To Paste Code In Jira
-
Biggest Heading - Text Formatting Notation Help - SLAC JIRA
-
Jira Integrations - GitLab Documentation
-
Template Comments (Jira Service Management)
-
Can We Write Code In Jira?
-
Code - Examples - Components - Atlassian Design System
-
Jira Mangles Inline Code Formatting In Github Issues/comments #2647