> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/create-jira-issues-in-cd-stages.md).

# Create Jira issues in CD stages

This topic describes how to create a Jira issue as a step in the execution of a pipeline.

You can create a Jira issue as a step in the execution of a pipeline using the Create Jira step. You can add the Create Jira step to a Harness Deploy stage or an Approval stage.

## What you will learn from this topic

* How to [add a Jira Create step](#add-a-jira-create-step) to a stage.
* How to [add issue fields](#add-issue-fields) and [reference fields with spaces](#referencing-jira-fields-with-spaces-or-special-characters-in-expressions) in expressions.
* How to set [Jira date fields](#jira-date-field-support) and [parent issues](#parent-issue-support).
* How to [apply and test](#apply-and-test) the step and view the new Jira issue.

***

## Before you begin <a href="#before-you-begin" id="before-you-begin"></a>

The following prerequisites apply to the Jira Create step:

* **Jira connector**: You can add a Harness Jira connector before or during the Create Jira step setup. Go to [Connect to Jira](/harness-platform/use-harness-platform/connectors/ticketing-systems/connect-to-jira.md) to create one.

***

## Limitations <a href="#limitations" id="limitations"></a>

The Jira Create step has the following limitations:

* Harness supports only Jira fields of type `User`, `Option`, `Array`, `Any`, `Number`, `Date`, and `String`. For example, [multi value](https://support.atlassian.com/jira-cloud-administration/docs/custom-fields-types-in-company-managed-projects/) fields to allow you to select multiple options from a dropdown list.
* Harness does not integrate with Jira fields that manage issue links or attachments.
* You can add unsupported Jira fields using an HTTP step. For more details, go to [Use the HTTP step to set unsupported fields when creating Jira issues](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/create-cascading-fields-jira.md).

{% hint style="warning" %}
**Each run creates a new issue**

While it is not a strict limitation, it is easy to forget that when you use a Jira Create step it creates a new, independent Jira issue every time it is run (as opposed to [updating](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/update-jira-issues-in-cd-stages.md) the same issue). Remember to add Jira Create to a stage only if you want to create a new Jira issue on every run of the stage.
{% endhint %}

***

## Add a Jira Create step <a href="#add-a-jira-create-step" id="add-a-jira-create-step"></a>

Perform the following steps to add a Jira Create step:

1. In a Harness Deploy or Approval stage, in **Execution**, select **Add Step**.
2. Select **Jira Create**. The Jira Create step appears.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-302b8d59c884046128c3a2d2bf388aa5449687a9%2Fcreate-jira-issues-in-cd-stages-00.png?alt=media)
3. In **Name**, enter a name that describes the step.
4. In **Timeout**, enter how long you want Harness to try to create the issue before failing (and initiating the stage or step [failure strategy](/harness-platform/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md)).
5. In **Jira Connector**, create or select the [Jira connector](/harness-platform/use-harness-platform/connectors/ticketing-systems/connect-to-jira.md) to use.
6. In **Jira 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.
7. In **Issue Type**, select a Jira issue type from the list of types in the Jira project you selected.
8. Select **Apply Changes**.
9. Select **Save**.

The fields that are required are determined by your definitions that are set in the project and issue in Jira.

{% hint style="info" %}
**Fields and security**

* Fields for a particular Issue Type must be modifiable in order to be added and set via the Harness Jira connector. For example, if the Requester Field cannot be edited, or has permission restrictions, then you can expect an error message when setting the field. For example, `Fields {Reporter} are invalid for the provided jira issue type`
* If you set Requesters and Assignees, make sure you take into account Atlassian settings and permissions to allow Assignees or Reporters to be searchable. If all other fields can be set, but no users can be listed, go to the [Atlassian information on missing users in Assignee or Reporter fields](https://confluence.atlassian.com/jirakb/cannot-find-users-in-assignee-or-reporter-fields-779158856.html).
  {% endhint %}

***

## Add issue fields <a href="#add-issue-fields" id="add-issue-fields"></a>

In Jira fields, you can select specific fields within a Jira issue. For more information on custom fields, go to [Jira custom fields](https://support.atlassian.com/jira-cloud-administration/docs/custom-fields-types-in-company-managed-projects/).

Go to [Limitations](#limitations) to review the supported issue fields and other limitations.

### Reference Jira fields with spaces or special characters in expressions <a href="#referencing-jira-fields-with-spaces-or-special-characters-in-expressions" id="referencing-jira-fields-with-spaces-or-special-characters-in-expressions"></a>

When you need to reference Jira custom field values using Harness expressions (for example, in conditional execution or when passing values between steps), fields that contain spaces or special characters must be enclosed in **single quotes** (`'`).

The following examples show the correct syntax.

**Fields with spaces**: use single quotes.

```
<+pipeline.stages.Jira_Stage.spec.execution.steps.Jira_Create.issue.'Risk Level'>
<+execution.steps.jiraCreate.issue.'Custom Field'>
```

**Fields without spaces**: no quotes are needed.

```
<+execution.steps.jiraCreate.issue.Status>
<+execution.steps.jiraCreate.issue.Priority>
```

**Using in conditional expressions**: the same quoting rule applies.

```
<+execution.steps.jiraCreate.issue.'Risk Level'> == "High"
```

{% hint style="info" %}
When referencing Jira issue fields created by the Jira Create step in subsequent steps or expressions, remember to use single quotes around field names that contain spaces or special characters.
{% endhint %}

***

## Jira date field support <a href="#jira-date-field-support" id="jira-date-field-support"></a>

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**:

![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-af3ebaa5e73ab59d77c6e7c9733c359e32744a05%2Fcreate-jira-issues-in-cd-stages-01.png?alt=media)

After you select these fields, they are available under **Optional Configuration**.

![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-88ee3d695ae0788120c5f15d018b87bf2a79646a%2Fcreate-jira-issues-in-cd-stages-02.png?alt=media)

You can also use advanced dates using Harness expressions and the `current()` function. The following examples show the syntax:

* `<+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, use:

`currentDate().plusYears(1).plusMonths(1).plusWeeks(1).plusDays(1)`

For date and time fields, use:

`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.

***

## Advanced settings <a href="#advanced-settings" id="advanced-settings"></a>

In **Advanced**, you can configure the following options for the step:

* [Delegate Selector](/harness-platform/use-harness-platform/delegates/delegate/manage-delegates/select-delegates-with-selectors.md)
* [Conditional Execution](/harness-platform/use-harness-platform/pipelines/step-skip-condition-settings.md)
* [Failure Strategy](/harness-platform/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md)
* [Looping Strategy](/harness-platform/use-harness-platform/pipelines/looping-strategies/looping-strategies-matrix-repeat-and-parallelism.md)
* [Policy Enforcement](/harness-platform/use-harness-platform/governance/policy-as-code/harness-governance-overview.md)

***

## Apply and test <a href="#apply-and-test" id="apply-and-test"></a>

Perform the following steps to apply changes and test the step:

1. Select **Apply Changes**. The Jira Create step is added to the stage.
2. Run the pipeline.
3. In the pipeline execution view, select the **Jira Create** step, and then select the **Output** tab. You can view all the fields for the new Jira issue you created.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-6151f4de0be5ae9a89844d90782c5a1f9a1ef9c1%2Fcreate-jira-issues-in-cd-stages-03.png?alt=media)
4. Locate **URL** and copy its value.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-1d28d1dbb01f73e74abecab8d3a32a830b9d2202%2Fcreate-jira-issues-in-cd-stages-04.png?alt=media)
5. In a new browser tab, paste the URL and click Enter.

   The new issue appears in Jira.

***

## Parent issue support <a href="#parent-issue-support" id="parent-issue-support"></a>

Harness supports parent links (the `issuelink` field in Jira).

This support enables you to do the following:

* The Jira Create step can be used to create issues with existing issues as their parent.
* The Jira Update step can be used to update the parent of a specific issue.
* A sub-task can be created using the Jira Create step.
* A ticket parent can be provided by typing the parent issue key in **Parent** setting, such as `TJI-47890`.

Perform the following steps to use parent links:

1. In the Jira Create or Update step, select **Optional Configuration**.
2. Select **Fields**.
3. In **Add Jira Fields**, select **Parent**, and select **Add**.

   ![picture 1](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-840d7385bbe7d25e9f6cd1a3d1d63d8e85dd9ff4%2Fcab823f2e376787040c80df674c55ea77863f3bca861a50d50052f7014893adf.png?alt=media)
4. In the **Value** for **Parent**, add the parent issue key.

   ![picture 2](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-a7e802c3971b1deca26d43d43db942014f94f59a%2Fc459f24248f46e308d03f01250b477480e555e8407bbfd1c6aa811a5054d0ef4.png?alt=media)

***

## Next steps

* [Update Jira issues in CD stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/update-jira-issues-in-cd-stages.md): Update an existing Jira issue from a pipeline step.
* [Use the HTTP step to set unsupported fields when creating Jira issues](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/create-cascading-fields-jira.md): Set Jira fields that the Jira Create step does not support.
* [Add Jira approval stages and steps](/harness-platform/use-harness-platform/approvals/adding-jira-approval-stages.md): Add Jira approvals to your pipeline.

{% @harness-feedback/feedback %}
