Skip to main content

snow-wait-for-condition

info

This promotion step is only available in Kargo on the Akuity Platform, versions v1.9.0 and above.

This page is for snow-wait-for-condition step. You can wait for a record field on a ServiceNow record to be set to a particular value before proceeding using this step. Check below for other ServiceNow promotion steps.

ServiceNow integration for kargo is a group of promotion steps:

  1. snow-create
  2. snow-update
  3. snow-delete
  4. snow-query-for-records
  5. snow-wait-for-condition

These steps provide a comprehensive integration with ServiceNow, allowing you to create, update, delete, query for records, and track promotion workflows. This is particularly useful for maintaining traceability between your promotion processes and project management activities.

All the steps above support different record types in ServiceNow including managing Change Requests, Incidents, Problems etc.,. This integration also provides condition tracking through snow-wait-for-condition, making it a powerful tool for promotion workflows that require coordination with project management systems.

Using the API

Most of the time you cannot use the field labels you see in the ServiceNow UI as keys in the REST API. For example, if you want to set the value for the “Short description” field:

You can't use Short description in the REST API. You need to use short_description as the key and set the value via REST API parameters. To find the correct key for a field, right-click on the field and click Configure Dictionary:

column_name is the key:

To see choices available for a particular field e.g., State, right click on the field and click on Show Choice List to see the available choices for use in the steps:

For example New is -1 and Scheduled is -2

Configuration

Credentials

All ServiceNow operations require proper authentication credentials stored in a Kubernetes Secret.

NameTypeRequiredDescription
credentials.secretNamestringYName of the Secret containing the ServiceNow credentials in the project namespace.
credentials.typestringYType of ServiceNow credentials to use for authentication (either api-token or basic).

For credentials.type: api-token the referenced Secret should contain the following keys:

  • apiToken: ServiceNow API Token (see this blog post for how to create an API token in ServiceNow).
  • instanceURL: Your ServiceNow instance URL.

For credentials.type: basic the referenced Secret should contain the following keys:

  • username: Username of the ServiceNow user (you may want to create a user specifically for this integration).
  • password: Password of the ServiceNow user (for how to set the password for a user, see this).
  • instanceURL: Your ServiceNow instance URL.

Record

NameTypeRequiredDescription
tableNamestringYTable name of the record type you want to wait on (e.g., incident, problem, change_request).
ticketIdstringYTicket ID (sys_id) of the record you want to monitor.
conditionstringYCondition to wait on before proceeding.

Output

This step does not produce any output.

Example

This example waits for a Change Request to be Scheduled (state=-2) before proceeding with promotion:

steps:
- as: snow-wait-for-condition
config:
condition: state=-2
credentials:
namespace: kargo-demo
secretName: snow-creds
type: api-token
tableName: change_request
ticketId: d457fbac6112287007379b57c6b2e60
uses: snow-wait-for-condition
# promotion steps continue after approval...
- uses: helm-template
config:
path: ./charts
vars:
imageTag: "${{ imageFrom(vars.imageRepo).Tag }}"
environment: "${{ ctx.stage }}"

You can write more complex conditions as well. See the list of supported operators here.

Different E2E Workflows

These examples demonstrate the different steps supported for ServiceNow integration.

Change API Workflow

  - as: snowcreate
config:
credentials:
secretName: snow-creds
type: api-token
parameters:
impact: "3"
short_description: Deploy to ${{ ctx.stage }} complete for ${{ vars.imageRepo
}}:${{ imageFrom(vars.imageRepo).Tag }}
urgency: "3"
tableName: change_request
template:
templateId: ed89b72c83c172104517e470ceaad30a
type: standard
uses: snow-create
- as: snowquery
config:
credentials:
namespace: kargo-demo
secretName: snow-creds
type: api-token
query:
number: ${{ task.outputs.snowcreate.number }}
tableName: change_request
uses: snow-query-records
- as: snowupdate
config:
credentials:
secretName: snow-creds
type: api-token
parameters:
short_description: Update deployment for ${{ vars.imageRepo }}:${{
imageFrom(vars.imageRepo).Tag }} to resolved
tableName: change_request
template:
type: standard
ticketId: ${{ task.outputs.snowquery.sys_id }}
uses: snow-update
- as: snow-wait-for-condition
config:
condition: state=-2
credentials:
namespace: kargo-demo
secretName: snow-creds
type: api-token
tableName: change_request
ticketId: ${{ task.outputs.snowquery.sys_id }}
uses: snow-wait-for-condition
- as: snowdelete
config:
credentials:
secretName: snow-creds
type: api-token
tableName: change_request
template:
type: standard
ticketId: ${{ task.outputs.snowquery.sys_id }}
uses: snow-delete

Table API Workflow

  - as: snowcreate
config:
credentials:
secretName: snow-creds
type: api-token
parameters:
impact: "3"
short_description: Deploy to ${{ ctx.stage }} complete for ${{ vars.imageRepo }}:${{ imageFrom(vars.imageRepo).Tag }}
urgency: "3"
tableName: incident
uses: snow-create
- as: snowquery
config:
credentials:
namespace: kargo-demo
secretName: snow-creds
type: api-token
query:
number: ${{ task.outputs.snowcreate.number }}
tableName: incident
uses: snow-query-records
- config:
ticketId: ${{ task.outputs.snowquery.sys_id }}
credentials:
secretName: snow-creds
type: api-token
parameters:
short_description: Update deployment for ${{ vars.imageRepo }}:${{ imageFrom(vars.imageRepo).Tag }} to resolved
tableName: incident
uses: snow-update
- as: snow-wait-for-condition
config:
condition: state=6
credentials:
namespace: kargo-demo
secretName: snow-creds
type: api-token
tableName: incident
ticketId: ${{ task.outputs.snowquery.sys_id }}
uses: snow-wait-for-condition
- as: snowdelete
config:
credentials:
secretName: snow-creds
type: api-token
tableName: incident
ticketId: ${{ task.outputs.snowquery.sys_id }}
uses: snow-delete

Here's a Table API workflow with Change Request:

  - as: snowcreate
config:
credentials:
secretName: snow-creds
type: api-token
parameters:
impact: "3"
short_description: Deploy to ${{ ctx.stage }} complete for ${{ vars.imageRepo
}}:${{ imageFrom(vars.imageRepo).Tag }}
urgency: "3"
tableName: change_request
uses: snow-create
- as: snowquery
config:
credentials:
namespace: kargo-demo
secretName: snow-creds
type: api-token
query:
number: ${{ task.outputs.snowcreate.number }}
tableName: change_request
uses: snow-query-records
- as: snowupdate
config:
credentials:
secretName: snow-creds
type: api-token
parameters:
short_description: Update deployment for ${{ vars.imageRepo }}:${{
imageFrom(vars.imageRepo).Tag }} to resolved
tableName: change_request
ticketId: ${{ task.outputs.snowquery.sys_id }}
uses: snow-update
- as: snow-wait-for-condition
config:
condition: state=-2
credentials:
namespace: kargo-demo
secretName: snow-creds
type: api-token
tableName: change_request
ticketId: ${{ task.outputs.snowquery.sys_id }}
uses: snow-wait-for-condition
- as: snowdelete
config:
credentials:
secretName: snow-creds
type: api-token
tableName: change_request
ticketId: ${{ task.outputs.snowquery.sys_id }}
uses: snow-delete