This steps performs a GraphQL call to Ontrack and returns the JSON response.
Parameter | Type | Default | Description |
---|---|---|---|
query |
String | Required | The GraphQL query or mutation |
variables |
Map | Optional | Map of GraphQL variables to pass to the call |
logging |
boolean | false |
Set to true to display debug / logging information while performing the call. |
url |
String | Computed | Ontrack URL. See below. |
token |
String | Computed | Ontrack API token. See below. |
ONTRACK_URL
- the URL of the Ontrack instance to connect to. It'll be typically declared globally but can also be explicitly defined in your pipeline.
ONTRACK_TOKEN
- the API token to use for the connection to Ontrack.
If this environment variable is not defined, this step will look for the ONTRACK_TOKEN_ID
environment variable (using ONTRACK_TOKEN
as a default value) in order to identify a credentials entry. This credentials entry will then be used to get the value of the token.
The response as a JSON object.
To get the list of projects in Ontrack:
script {
def answer = ontrackCliGraphQL(query: '''
{
projects {
name
}
}
''')
// Printing all projects
answer.data.projects.each { project ->
echo "Project = ${project.name}"
}
}