> 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/harness-ai/use-harness-platform/approvals/adding-jira-approval-stages.md).

# Adding Jira approval stages and steps

Use Jira issues to approve or reject a Pipeline or stage at any point in its execution.

You can use Jira issues to approve or reject a Pipeline or stage at any point in its execution.

During deployment, a Jira issue's fields are evaluated according to criteria you define and its approval/rejection determines if the Pipeline or stage may proceed.

The **Jira Approval** step can be added in a Jira Approval stage or in a Continuous Delivery stage. The Jira Approval step prevents the stage execution from proceeding without an approval.

For example, in a [Kubernetes Blue Green Deployment](/continuous-delivery/use-continuous-delivery/deploy-services-on-different-platforms/kubernetes/kubernetes-executions/create-a-kubernetes-blue-green-deployment.md), you might want to add an approval step between the Stage Deployment step, where the new app version is deployed to the staging environment, and the Swap Primary with Stage step, where production traffic is routed to the pods for the new version.

To create or update Jira issues, go to [Create Jira issues in CD stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/create-jira-issues-in-cd-stages.md) and [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).

#### Visual summary <a href="#visual-summary" id="visual-summary"></a>

The following video shows you how to use the Jira Create, Jira Update, and Jira Approval steps:

{% embed url="<https://www.youtube.com/embed/xVeICozz4lU>" %}
Use the Jira Create, Jira Update, and Jira Approval steps
{% endembed %}

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

The Jira Approval step reads a limited set of Jira field types:

* Harness supports only Jira fields of type `Option`, `Array`, `Any`, `Number`, `Date`, and `String`. 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 the Harness Jira integration.
* Array-type fields (such as **Labels**) cannot be used in the **Conditions** section of approval criteria. Only string and option-type fields are supported for key-value criteria. To evaluate array-type fields, use JEXL expressions in the **JEXL Expression** field instead. For example, to check if a label exists, use `<+issue.Labels>.indexOf('your-label') >= 0`.

#### Jira approval stages and steps <a href="#review-jira-approval-stages-vs-steps" id="review-jira-approval-stages-vs-steps"></a>

You can use Jira Approvals in two ways:

* **Jira Approval step**: You can add a Jira Approval step to any Continuous Delivery or Approval stage.
* **Jira Approval stage**: The Jira Approval stage includes Jira Create, Jira Approval, and Jira Update steps:

![Jira Approval stage with Jira Create, Jira Approval, and Jira Update steps](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-91f30f09cfb948f825fa1d2a36469c8d1696cf31%2Fadding-jira-approval-stages-08.png?alt=media)

You do not need to use the Jira Create and Jira Update steps with the Jira Approval step, but they are included in the Jira Approval stage because the stage is meant to create a Jira issue, approve or reject based on its settings, and then update the Jira issue in one stage.

You can also use the Jira Create, Jira Approval, and Jira Update steps within a non-Approval stage.

The Jira Create and Jira Update steps are described in other topics. This topic describes the Jira Approval step only.

See:

* [Create Jira Issues in CD Stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/ticketing-systems/create-jira-issues-in-cd-stages.md)
* [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)

#### Add a Jira Approval step <a href="#step-1-add-a-jira-approval-step" id="step-1-add-a-jira-approval-step"></a>

In a CD or Approval stage, click **Add Step**, and then click **Jira Approval**.

When you add a Jira Approval stage, Harness automatically adds Jira Create, Jira Approval, and Jira Update steps. This topic covers only the Jira Approval step.

In **Name**, enter a name that describes the step.

In **Timeout**, enter how long you want Harness to try to complete the step before failing (and initiating the stage or step [Failure Strategy](https://developer.harness.io/docs/platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps)).

You can use `w` for week, `d` for day, `h` for hour, `m` for minutes, `s` for seconds, and `ms` for milliseconds. For example, `1d` is one day.

Jira communication can take a few minutes. Do not use a brief timeout.

The maximum is 3w 3d 20h 30m. In **Jira Connector**, create or select the [Jira Connector](https://developer.harness.io/docs/platform/connectors/ticketing-systems/connect-to-jira/) to use.

In **Project**, select the Jira project that contains the issue you want to evaluate.

In **Issue Key**, enter the Jira issue key of the issue you want to evaluate.

In **Retry Interval**, set how long the step should wait to fetch details again for calculating Approval or Rejection criteria.

#### Pass Jira issue keys with expressions <a href="#passing-jira-issue-keys-using-expressions" id="passing-jira-issue-keys-using-expressions"></a>

In **Issue Key**, you can use an expression to reference the issue key from another Jira Create or Jira Update step.

<details>

<summary>Example pipeline</summary>

The following example shows a Jira Create step (with the Id `Jira_Create`) and two subsequent Jira Update steps, JiraUpdate\_1 and JiraUpdate\_2.

JiraUpdate\_1 references the issue key from the Jira Create step using the expression `<+pipeline.stages.Jira_Stage.spec.execution.steps.Jira_Create.issue.key>`.

JiraUpdate\_2 references the issue key from JiraUpdate\_1 using the expression `<+execution.steps.JiraUpdate_1.spec.issueKey>`, but it could also use the expression `<+pipeline.stages.Jira_Stage.spec.execution.steps.Jira_Create.issue.key>`.

```yaml
pipeline:
  name: Jira
  identifier: Jira
  projectIdentifier: CD_Docs
  orgIdentifier: default
  tags: {}
  stages:
    - stage:
        name: Jira Stage
        identifier: Jira_Stage
        description: ""
        type: Approval
        spec:
          execution:
            steps:
              - step:
                  name: Jira Create
                  identifier: Jira_Create
                  type: JiraCreate
                  timeout: 5m
                  spec:
                    connectorRef: Jira
                    projectKey: TJI
                    issueType: Bug
                    fields:
                      - name: Summary
                        value: test for doc
              - step:
                  type: JiraUpdate
                  name: JiraUpdate_1
                  identifier: JiraUpdate_1
                  spec:
                    connectorRef: Jira
                    issueKey: <+pipeline.stages.Jira_Stage.spec.execution.steps.Jira_Create.issue.key>
                    transitionTo:
                      transitionName: ""
                      status: In Progress
                    fields: []
                  timeout: 10m
              - step:
                  type: JiraUpdate
                  name: JiraUpdate_2
                  identifier: JiraUpdate_2
                  spec:
                    connectorRef: Jira
                    issueKey: <+execution.steps.JiraUpdate_1.spec.issueKey>
                    transitionTo:
                      transitionName: ""
                      status: Will Not Fix
                    fields: []
                  timeout: 10m
        tags: {}
```

</details>

The following video demonstrates how to pass an issue key:

{% embed url="<https://www.loom.com/share/c3e9e58ee8044b70994af2c103408223?sid=b6c9de26-f737-4860-889d-2cc9611043d7>" %}
Pass a Jira issue key between steps
{% endembed %}

The expression follows the format `<+pipeline.stages.STAGE_ID.spec.execution.steps.STEP_ID.issue.key>`.

{% hint style="info" %}
**Important**

The Jira Create or Jira Update step you want to reference must be **before** the Jira Update step that references it in the pipeline and stage.
{% endhint %}

There are two ways to get the information for the expression:

* **Use the standard expression**: In the Jira Update step **Issue Key**, select **Expression**, and then paste the expression `<+pipeline.stages.STAGE_ID.spec.execution.steps.STEP_ID.issue.key>` with the correct `STAGE_ID` and `STEP_ID` values for the Jira Create step that creates the issue key.

  ![Expression option selected for the Issue Key field](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-ab592a11a1000e96ee1f8f2f0efbb203f4ca9b21%2Ff1e2ce091ba77fae22dbafbd06e9e2a994a13850118aa1700043c126f53eda7c.png?alt=media)

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>When the Jira <strong>Create</strong> step is open in Pipeline Studio, copy the <code>STAGE_ID</code> and <code>STEP_ID</code> values from the browser URL: <code>stageId=STAGE_ID&#x26;sectionId=EXECUTION&#x26;stepId=steps.0.step.STEP_ID</code>.</p><p>For example, <code>stageId=Jira_Stage&#x26;sectionId=EXECUTION&#x26;stepId=steps.0.step.Jira_Create</code>.</p></div>
* **Copy the expression from an executed step**: Select a successful execution, and click the Jira Create step in the execution.

  * Click the **Output** tab, locate the **Key** setting, and click the copy button.

  ![Output tab showing the issue key to copy](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-5fdab13b7cde0552a6384330f8a440bb2af59bc4%2Fadding-jira-approval-stages-09.png?alt=media)

  Now you have the expression that references the issue key from this step.

  Go back to the Jira Update step. Select **Edit Pipeline**.

  In **Issue Key**, select **Expression**.

  ![Expression pasted into the Issue Key field](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-4ba0064c7ee95f2dd7d8aabc2f55ff1c23241358%2Fadding-jira-approval-stages-10.png?alt=media)

  In **Issue Key**, paste in the expression you copied from the previous Jira Create/Update step.

With either method, the Jira Update step will use the issue created by the Jira Create step.

A Jira Create step creates a new, independent Jira issue every time it runs. If you use the same issue ID in Jira Approval, each run approves a new issue.

#### Set approval criteria <a href="#step-2-set-approval-criteria" id="step-2-set-approval-criteria"></a>

The **Approval Criteria** in the step determines if the Pipeline or stage is approved or rejected.

![Approval criteria with conditions and a JEXL expression](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-2f2a32370604d0bcd5c2c712d866bab88566c798%2Fadding-jira-approval-stages-11.png?alt=media)

Whether the Pipeline/stage stops executing depends on the stage or step [Failure Strategy](https://developer.harness.io/docs/platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps). You can specify criteria using **Conditions** and/or **JEXL Expression**. If you use them in combination they both must evaluate to `True` for the step to be successful.

In **Conditions**, use the Jira field, operator, and value to define approval criteria. Four supported operators are `=`, `!=`, `in`, and `not in`. For example:

* The condition for the `Status` field to be in `Approved`, `Done`, or `Published` can be specified as: ![Status in Approved, Done, or Published](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-037ca1ac81b847482cf29f1f4731396dbb929fbf%2Fadding-jira-approval-stages-15.png?alt=media)
* The condition for the `Status` field to not be in either `Blocked`, `Invalid`, or `To Do` can be specified as: ![Status not in Blocked, Invalid, or To Do](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-21f38eb0b429b9502d0c78abf4d6968bbe702b46%2Fadding-jira-approval-stages-16.png?alt=media)
* The condition for the `Status` field to be in `Approved`, `Done`, or `Published` without `Issue Type` can be specified as: ![Status in Approved, Done, or Published with no Issue Type](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-3f0d8fa1dc2b25a23c7bf4c6ef2daeb420935965%2Fadding-jira-approval-stages-17.png?alt=media)

{% hint style="info" %}
**Important**

Multiple conditions with the same Jira field are not allowed. Such use cases can be solved using `in`, `not in` operators, or **JEXL Expression**.
{% endhint %}

In **JEXL Expression**, you can use [JEXL expressions](https://commons.apache.org/proper/commons-jexl/reference/syntax.html). You can use a JEXL expression if the field is set to **Fixed value**, **Runtime input**, or **Expression**.

**Using JEXL expressions for array-type fields**

Array-type fields like **Labels** cannot be evaluated using the **Conditions** section. Instead, use JEXL expressions to check these fields.

For example, to approve when a specific label exists on the Jira issue:

```
<+issue.Labels>.indexOf('your-label') >= 0
```

This expression returns `true` if the Labels array contains "your-label".

**Additional examples**:

* Check if Labels contains "fed":

  ```
  <+issue.Labels>.indexOf('fed') >= 0
  ```
* Check if Labels contains "approved" OR "verified":

  ```
  <+issue.Labels>.indexOf('approved') >= 0 || <+issue.Labels>.indexOf('verified') >= 0
  ```
* Check if Labels contains "high-priority" AND Status is "Done":

  ```
  <+issue.Labels>.indexOf('high-priority') >= 0 && <+issue.Status> == "Done"
  ```

#### Set rejection criteria <a href="#option-set-rejection-criteria" id="option-set-rejection-criteria"></a>

In **Optional Configuration**, in **Rejection Criteria**, you can define criteria for rejecting the approval.

If you add rejection criteria it is used in addition to the settings in **Approval Criteria**.

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

In Advanced, you can use the following options:

* [Step Skip Condition Settings](https://developer.harness.io/docs/platform/pipelines/step-skip-condition-settings)
* [Step Failure Strategy Settings](https://developer.harness.io/docs/platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps)

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

Click **Apply Changes**. The Jira Update step is added to the stage.

Run the Pipeline.

When the Jira Approval step is reached, you can see its approval and rejection criteria:

![Jira Approval step showing approval and rejection criteria during execution](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-b84ed9c638941f03e8798552f2cd3e587e2d3fb9%2Fadding-jira-approval-stages-12.png?alt=media)

You can also click the **JIRA Ticket Pending Approval** link to open the ticket.

The step can take a few minutes to receive information from Jira.

#### Issue expressions <a href="#review-issue-expressions" id="review-issue-expressions"></a>

You can use `<+issue>` to refer to the value in the **Issue Key** setting.

For example, `<+issue.Status> == "Done"` in the Approval Criteria **JEXL Expression** checks whether the status of the issue in **Issue Key** is **Done**:

![JEXL expression checking that issue status is Done](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-8565230f43d927ae1a9984a0bce6a97f36ea228b%2Fadding-jira-approval-stages-13.png?alt=media)

`Status` is an issue field. You can use any issue field.

**Referencing JIRA fields with spaces or special characters**

When referencing JIRA custom fields that contain spaces or special characters in their names, you must enclose the field name in **single quotes** (`'`) within the Harness expression. Without quotes, the expression evaluation will fail.

**Examples**:

**Fields with spaces, correct syntax**:

```
<+issue.'Risk Level'> == "High"
<+issue.'1-line Update'> == "test"
<+issue.'Remaining Estimate'> == "2h"
```

**Fields without spaces, no quotes needed**:

```
<+issue.Priority> == "P1"
<+issue.Status> == "Done"
<+issue.Description> == "new description"
```

**Complex expression combining both**:

```
((<+issue.'Risk Level'> == "High") && (<+issue.Labels>.indexOf('crm-approved') >= 0)) || (<+issue.'Risk Level'> == "Low")
```

This expression checks if:

* The "Risk Level" custom field equals "High" AND the Labels field contains "crm-approved", OR
* The "Risk Level" custom field equals "Low"

**Incorrect syntax (the expression fails)**:

```
<+issue.Risk Level> == "High"  // FAILS - no quotes around field name with space
<+issue.customfield_1234> == "High"  // May work for custom field IDs, but use field names with quotes for better readability
```

{% hint style="info" %}

* Use single quotes (`'`) around field names that contain spaces or special characters
* Standard field names without spaces (like `Status`, `Priority`, `Labels`) do not require quotes
* For better readability, use the custom field name with quotes rather than the `customfield_XXXX` identifier
  {% endhint %}

**Additional examples**:

```
<+issue.Priority> == "P1" && <+issue."1-line Update"> == "test" && <+issue."Remaining Estimate"> == "2h" && <+issue.Description> == "new description"
```

#### Refresh status during execution <a href="#manual-refresh-during-execution" id="manual-refresh-during-execution"></a>

You can do a **manual status refresh** in the Pipeline Studio Execution view.

When the step is waiting for a response from Jira, you can use the **Refresh** button to immediately fetch the **latest status of the approval ticket** instead of waiting for the polling interval.

Use the refresh option when:

* The approval condition in Jira was updated after the step began execution.
* You need quicker response handling for fast-track approvals such as incident mitigations or emergency changes.

To use the refresh button:

* Execute a pipeline with a Jira Approval step.
* In the Pipeline Studio Execution view, locate the approval step.
* If the step is in a waiting state, click the Refresh button.
* The step re-evaluates the condition and proceeds if the criteria are met.

#### Notes <a href="#notes" id="notes"></a>

* To add comments in you can use **Comment** key. Use `\\` for line breaks.

![Comment key used to add a comment on the Jira issue](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-373ffcdcbb74ac61a0c41b13d49833a8629c8a35%2Fadding-jira-approval-stages-14.png?alt=media)

* For more information about approval log limitations, go to [Deployment logs and limitations](/continuous-delivery/use-continuous-delivery/manage-deployments/deployment-logs-and-limitations.md).

{% @harness-feedback/feedback module="harness-ai" pagePath="harness-ai/use-harness-platform/approvals/adding-jira-approval-stages" %}
