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

# Adding Jira approval stages and steps

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 Jira Approval stages or in CD stages. 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.

Looking to create or update Jira issues? 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).

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

* [Connect to Jira](/harness-ai/use-harness-platform/connectors/ticketing-systems/connect-to-jira.md)
* [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)

#### 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>" %}

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

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

#### Review: Jira Approval Stages vs 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 CD or Approval stage.
* **Jira Approval stage:** the Jira Approval stage includes Jira Create, Jira Approval, and Jira Update steps:

![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/TuVCaoQyQQ9E5zoShlcf)

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 many users want to create a Jira issue, approve/reject based on its settings, and then update the Jira issue all in one stage.

You can also achieve this simply by using 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)

#### Step 1: 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. We'll only cover the Jira Approval step here.

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](/harness-ai/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md)).

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 for 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](/harness-ai/use-harness-platform/connectors/ticketing-systems/connect-to-jira.md) 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.

#### Passing Jira issue keys using 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>

Here's an example pipeline showing 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>

Here's a video that demonstrates how to pass an issue key:

{% embed url="<https://www.loom.com/share/c3e9e58ee8044b70994af2c103408223?sid=b6c9de26-f737-4860-889d-2cc9611043d7>" %}

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.

  ![picture 0](/spaces/y1JhZ4oKIppwY7d5AhPj/files/IeJCUXwQdJw5Tony5c87)

  <div data-gb-custom-block data-tag="hint" data-style="info" class="hint hint-info"><p>When you have the Jira <strong>Create</strong> step open in Pipeline Studio, you can 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.

  ![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/wkpGaEqdy2HN6X13GGXM)

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

  Go back to your Jira Update step. You can just select **Edit Pipeline**.

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

  ![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/JDlzqoyfy3Wpfm6ORzFq)

  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.

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 Approval, you are approving using a new issue every run.

#### Step 2: 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.

![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/veGPhK2LyloGzwg6CkBl)

Whether the Pipeline/stage stops executing depends on the stage or step [Failure Strategy](/harness-ai/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md). 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**, you simply 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: ![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/nQexD6XV7Tg9qhNvg5Ad)
* The condition for the `Status` field to not be in either `Blocked`, `Invalid`, or `To Do` can be specified as: ![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/y3rEKlNCmehhYyEhKszS)
* The condition for the `Status` field to be in `Approved`, `Done`, or `Published` without `Issue Type` can be specified as: ![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/SH2gHFJPCa8YAdH3XhoH)

{% 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"
  ```

#### Option: 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**.

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

In Advanced, you can use the following options:

* [Step Skip Condition Settings](/harness-ai/use-harness-platform/pipelines/step-skip-condition-settings.md)
* [Step Failure Strategy Settings](/harness-ai/use-harness-platform/pipelines/failure-handling/define-a-failure-strategy-on-stages-and-steps.md)

#### Step 3: 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:

![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/pdZ15PhLJ4OiikQ14Tus)

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.

#### Review: 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 to see in the status of the issue in Issue Key is **Done**:

![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/L8d8Kc7k8GxFXSbup6E2)

`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 (will fail):**

```
<+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`) don't 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"
```

#### Manual Refresh 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 will re-evaluate the condition and proceed 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.

![](/spaces/y1JhZ4oKIppwY7d5AhPj/files/3K0YBMxnnKvYPxJDkF70)

* 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).

#### See also <a href="#see-also" id="see-also"></a>

* [Using Manual Harness Approval Stages](/harness-ai/use-harness-platform/approvals/adding-harness-approval-stages.md)
* [Using Manual Harness Approval Steps in CD Stages](/continuous-delivery/use-continuous-delivery/cd-building-blocks/cd-steps/approvals/using-harness-approval-steps-in-cd-stages.md)
