Automating Jobs with Pipelines
Creating a Pipeline
To create a pipeline, you will want multiple jobs created. After you have created 2+ jobs you can get started with creating a pipeline. You can use the pipeliner API to do this.
Create an Empty Pipeline
The best way to create a pipeline is to do it in iterations. Start by creating an empty pipeline using the /pipelines endpoint.
This will create a pipeline without any steps. The response will include the pipelineId
. You should save this value to be reused.
Add a Job to a Pipeline
To add jobs to a pipeline, you will need the:
Pipeline ID
Job ID
Step order
Using all three of these values you can add a job to the pipeline by using the /pipelines/{{pipelineID}/job endpoint. This example adds three jobs to the pipeline. Two at step 0 and one at step 1.
Based on the step order provided, the job will be added to that step. When a pipeline runs, it will run all steps in their provided order. So in this example jobs 87f... and 3a7... will run in parallel before job 337...
The response to this request will show the updated pipeline, allowing you to verify that it looks as expected.
Removing a Job From a Pipeline
The same endpoint to add a job to a pipeline step can be used to remove a job from a pipeline step. The payload is the same for both the DELETE and POST requests.
The response to this request will show the updated pipeline, allowing you to verify that it looks as expected.
Updating a Pipeline
To update the pipeline with a new name or add multiple jobs/steps in a single request you can use the /pipelines/{{pipelineID}} endpoint.
First you will need to get the current pipeline.
The response will return the pipeline object. You can then manipulate this object to add more steps, jobs, or update the name of the pipeline.
For example, taking the above response you can change the name of the pipeline.
Once the object has be edited you can send it as a payload to the same endpoint in a PUT request.
As stated in the API doc, you will need to list every value in the request. Otherwise the value will be defaulted and likely lost.
Running a Pipeline
Like a job pipelines can be run. This is done by using the pipeliner's /pipelines/{{pipelineID}}/start endpoint. This request will start a pipeline transaction
which is combination of standard syncTransactions
.
The response will include the id
of the pipeline transaction
. This can be used to track the status of the transaction.
Tracking Pipeline Transaction Status
To track the status of the pipeline transaction, you can use the /pipelines/{{pipelineID}}/transactions/{{transactionID}} endpoint.
The response will show the list of sync transaction started by the pipeline. You can then view the status of each individual sync transaction. The response will also show if the pipeline transaction is active and the last step that was completed by the pipeline.
Canceling a Pipeline Transaction
Similar to a sync transaction you can also cancel a pipeline transaction. You can use the /pipelines/{pipelineID}/transactions/{transactionID}/cancel endpoint.
This will cancel all sync transactions related to this pipeline transaction stopping the processes from continuing further.
Last updated