To run your pipeline and verify that it completes successfully, you make a POST request with the pipeline ID and monitor the run.
Prerequisites
- Verify that all general prerequisites and prerequisites for the Automation Pipelines service have been satisfied. See Prerequisites for API Use Case Examples.
- Verify that you have the ID for the pipeline that you created. See Create and Enable a Pipeline.
Procedure
Example: Run and Monitor your Pipeline
Using the ID for the pipeline named jenkinspipeline that you created, run and monitor the pipeline.
Assign variables.
$ url='https://appliance.domain.com'
$ api_version='2019-10-17'
$ pipeline_id='2677aa61-578a-4465-a653-a3c787fed3be'
Run your pipeline.
$ curl -X POST \
$url/codestream/api/pipelines/$pipeline_id/executions?apiVersion=$api_version \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $access_token" \
-d '{
"comments":"",
"input":{}
}' | jq "."
The response from your request shows the execution ID.
{
"executionId": "6fc8e571-418e-4b07-b869-e661fdbdf29f",
"executionLink": "/codestream/api/executions/6fc8e571-418e-4b07-b869-e661fdbdf29f",
"executionIndex": 0
}
Assign the execution ID variable.
$ execution_id='6fc8e571-418e-4b07-b869-e661fdbdf29f'
Monitor the run.
$ curl -X GET $url/codestream/api/executions/$execution_id?apiVersion=$api_version -H 'Content-Type: application/json' -H "Authorization: Bearer $access_token" | jq "."
Continue to monitor the pipeline activity until the response shows the task and run completed successfully.
{
"project": "MyProject1",
"id": "6fc8e571-418e-4b07-b869-e661fdbdf29f",
"name": "jenkinspipeline",
"updatedBy": "[email protected]",
"updatedAt": "2022-11-04 11:26:25.283",
"_link": "/codestream/api/executions/6fc8e571-418e-4b07-b869-e661fdbdf29f",
...
"stageOrder": ["Stage0"],
"stages": {
"Stage0": {
"status": "COMPLETED",
"statusMessage": "COMPLETED",
"taskOrder": ["Task0"],
"tasks": {
"Task0": {
"type": "Jenkins",
"name": "Task0",
"id": "6fc8e571-418e-4b07-b869-e661fdbdf29f~0.0.0",
...
},
"status": "COMPLETED",
"statusMessage": "Jenkins task completed successfully.",
"_durationInMicros": 35915000,
"_startTime": 1667561149181000,
"_endTime": 1667561185160000
}
},
"_durationInMicros": 36000000,
"_startTime": 1667561149160000,
"_endTime": 1667561185223000,
"notifications": []
}
},
"status": "COMPLETED",
"statusMessage": "Execution Completed.",
...