Update Jira issues in CD stages
This topic describes how to update a Jira issue using the Update Jira step.
You can add the Update Jira step to a Harness CD stage or an Approval stage.
You can also update Jira issues and add Jira approval stages and steps.
Before you begin
- Connect to Jira: You can add a Harness Jira connector before or during the Create Jira step setup.
- Adding Jira approval stages and steps
Visual Summary
The following video shows you how to use the Jira Create, Jira Update, and Jira Approval steps:
Limitations
- Harness supports only Jira fields of type
Option
,Array
,Any
,Number
,Date
, andString
. Harness does not integrate with Jira fields that manage users, issue links, or attachments. This means that Jira fields like Assignee and Sprint are not accessible in Harness' Jira integration.
Add a Jira Update step
- In a Harness CD or Approval stage, in Execution, select Add Step.
- Select Jira Update. The Jira Update step appears.
- In Name, enter a name that describes the step.
- In Timeout, enter how long you want Harness to try to update the issue before failing (and initiating the stage or step failure strategy).
- In Jira Connector, create or select the Jira connector to use.
- In Project, select a Jira project from the list. A Jira project is used to create the issue key and ID when the issue is created. The unique issue number is created automatically by Jira.
- In Issue Type, select a Jira issue type from the list of types in the Jira project you selected.
Use an expression in Issue Key
In Issue Key, you can use an expression to reference the Key ID from another Jira Create or Jira Update step.
The Jira Create or Jira Update step you want to reference must be before the Jira Update step that references it in the stage.
First, identify the step where you want to get the ID from. In this example, we'll use a Jira Create step.
You'll have to close the Jira Update step to get the the ID from the previous step. An ID is required, so you can just enter any number for now and click Save. In the pipeline, select Execution History.
Select a successful execution, and click the Jira Create step in the execution.
Select the Output tab, locate the Key setting, and select the copy button.
The expression will look something like this:
<+pipeline.stages.Jira_Stage.spec.execution.steps.jiraCreate.issue.key>
Now you have the expression that references the key ID from this step.
Go back to your Jira Update step. You can just select Edit Pipeline.
In Issue Key, select Expression.
Issue Key, paste in the expression you copied from the previous Jira Create step.
Now this Jira Update step will update the issue created by the Jira Create step.
Some users can forget that when you use a Jira Create step it creates a new, independent Jira issue every time it is run. If you are using the same issue ID in Jira Update, you are updating a new issue every run.
Optional configuration
In Optional Configuration:
- In Status, enter the status type (Issue Action) to update the issue with (In Progress, Done, etc). Harness will automatically update the issue with this status.
- In Transition Name, enter the name of the transition to move the issues into (for example,
Transition to
,PR Testing
,Ready for Test
).
If the issue is not part of a Jira workflow and does not have transition options, then the step will fail. For more information, go to statuses and transitions from Atlasssian.
Add Issue fields
You can select specific fields to update within a Jira issue. For more information, go to Jira custom fields.
In Optional Configuration, select + Fields to add Jira fields.
Jira Date field support
Among the custom fields Harness supports are Baseline End Date and Start Date Time. If your Jira project uses these fields, they are available in Fields:
Once you have selected these fields their settings appear.
You can also use advanced dates using stage variables and the current()
function. For example:
<+currentDate().plusDays(2).plusMonths(1)>
: current date plus one month and two days.<+currentTime()>
: for current date time fields.
Harness supports the following functions.
For date-only fields:
currentDate().plusYears(1).plusMonths(1).plusWeeks(1).plusDays(1)
For date and time fields:
currentTime().plusYears(1).plusMonths(1).plusWeeks(1).plusDays(1).plusHours(1).plusMinutes(1).plusSeconds(1).plusNanos(1)
The number 1 is used as an example. You can add whatever number you need.
Update Issue Type field support
Harness supports updating the Jira Issue Type.
Enter an Issue Key in the Jira Update step.
In the Add Jira Fields dialog, select Issue Type, then select Add. The Issue Type field appears under Optional Configuration.
Select a new issue type to modify the Issue Type of the selected Jira issue, and select Apply Changes.
The issue type for the selected Jira Issue is now updated with the issue type you selected.
Advanced settings
In Advanced, you can use the following options:
Apply and test
Select Apply Changes. The Jira Update step is added to the stage.
Run the pipeline.
In the pipeline execution view, select the Jira Update step, and then select the Output tab.
You can see all of the fields for the new Jira issue you created.
Locate URL and copy its value.
In a new browser tab, paste the URL and press enter.
The updated issue appears in Jira.