Use Workflows API

Updated 3 months ago by Archana Singh

This topic lists example queries that you can execute against the Harness Workflows API.

In this topic:

Before You Begin

Show Execution Details

This sample retrieves rich details on the parameters and results of (up to) 100 recent executions.

Request
{
executions(limit: 5) {
pageInfo {
limit
offset
total
}
nodes {
id
application {
id
name
}
status
cause {
... on ExecutedByUser {
user {
email
}
}
... on ExecutedByTrigger {
trigger {
id
name
}
}
}
... on PipelineExecution {
pipeline {
id
name
}
}
... on WorkflowExecution {
workflow {
id
name
}
outcomes{
nodes{
... on DeploymentOutcome{
service{
id
name
}
environment{
id
name
}
}
}
}

}
}
}
}
Response
{
"data": {
"executions": {
"pageInfo": {
"limit": 5,
"offset": 0,
"total": 20131
},
"nodes": [
{
"id": "-xxXXARHS9CPu-5YyYYy1jQ",
"application": {
"id": "-xxXXAAAAAa-5YyYYyJnQ",
"name": "Harness"
},
"status": "SUCCESS",
"cause": {
"user": {
"email": "xxx@test.io"
}
},
"workflow": {
"id": "1x1X1XxxXXedUdrlUxdfOw",
"name": "Ingress Controller"
},
"outcomes": {
"nodes": [
{
"service": {
"id": "0-xw1xX0XXmXXzLgiE9bEg",
"name": "ingress-controller"
},
"environment": {
"id": "1xX1-xXXQnKI8Q-XxaOA8w",
"name": "PR"
}
}
]
}
},
{
"id": "1xxxXx69QC2rj38zxa11uQ",
"application": {
"id": "-jXxxxXXXoOLj2NEhrbJnQ",
"name": "Harness"
},
"status": "SUCCESS",
"cause": {
"user": {
"email": "yyy@test.io"
}
},
"workflow": {
"id": "Ko1KigXXXXa7WMcXXleE6w",
"name": "UI"
},
"outcomes": {
"nodes": [
{
"service": {
"id": "XX8fn91XXXXxx8pS2_Vmg",
"name": "ui"
},
"environment": {
"id": "Xx2hXXXuTiqwn_MTbykXXX",
"name": "Dev"
}
}
]
}
},
{
"id": "xxALq5tdReyufXxQf_XXXX",
"application": {
"id": "-jXxxxXXXoOLj2NEhrbJnQ",
"name": "Harness"
},
"status": "RUNNING",
"cause": {
"user": {
"email": "xxy@test.io"
}
},
"pipeline": {
"id": "2XxXxKPrSMSnHTXvR1j0xX",
"name": "PR Harness"
}
},
{
"id": "x2x_Xxx-QymNF8WOWuwsIg",
"application": {
"id": "-jXxxxXXXoOLj2NEhrbJnQ",
"name": "Harness"
},
"status": "SUCCESS",
"cause": {
"user": {
"email": "xyy@test.io"
}
},
"pipeline": {
"id": "V_5CKgjsT3akXXXXXbM7lw",
"name": "PR Wakeup"
}
},
{
"id": "7FG-5x8XQKCiKrpvqXXdXx",
"application": {
"id": "-jRbnwXXXoOLj2NEhrbXxX",
"name": "Harness"
},
"status": "SUCCESS",
"cause": {
"trigger": {
"id": "ez-XXpCATZmybfpO2rxxxx",
"name": "Cleanup PR Namespaces"
}
},
"workflow": {
"id": "X3xxx_9CRbCshBAYfXXXXX",
"name": "PR Cleanup"
},
"outcomes": {
"nodes": [
{
"service": {
"id": "XxxxxxxXX8GwK6fESr1BoQ",
"name": "no-artifact"
},
"environment": {
"id": "1xX1-jMXQnKI8Q-XxaOA8w",
"name": "PR"
}
}
]
}
}
]
}
}
}

Show Executions for a Given Workflow

This sample queries by workflowId to return up to 30 deployments.

Request

{
executions(
filters: [
{ workflow: { operator: EQUALS, values: ["<workflowId>"] } }
]
limit: 30
) {
pageInfo {
total
}
nodes {
id
}
}
}
Response
{
"data": {
"executions": {
"pageInfo": {
"total": 3
},
"nodes": [
{
"id": "qliQv1XXXXa4bXXXxLPy4A"
},
{
"id": "rVwS1cXXXXXgdYIzwEKtCw"
},
{
"id": "TFO2a5XxXxXxkbPfsfDklg"
}
]
}
}
}


How did we do?