5.6. Annotations for specifying automatic cancellation-in-progress for a pipeline run
By default, Pipelines as Code does not cancel pipeline runs automatically. Every pipeline run that Pipelines as Code creates and starts executes until it completes. However, events that trigger pipeline runs can come in quick succession. For example, if a pull request triggers a pipeline run and then the user pushes new commits into the pull request source branch, each push triggers a new copy of the pipeline run. If several pushes happen, several copies can run, which can consume excessive cluster resources.
You can configure a pipeline run to enable automatic cancellation-in-progress. If you enable automatic cancellation for a pipeline run, Pipelines as Code cancels the pipeline run in the following situations:
- Pipelines as Code has successfully started a copy of the same pipeline run for the same pull request or the same source branch.
- The pull request that triggered the pipeline run is merged or closed.
You can use the following example to enable automatic cancellation when you create the sample-pipeline pipeline run:
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: sample-pipeline
annotations:
pipelinesascode.tekton.dev/cancel-in-progress: "true"
# ...
Automatic cancellation-in-progress of pipeline runs is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.
For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.
-
Pipelines as Code cancels a pipeline run after starting a new copy of this pipeline run successfully. The
pipelinesascode.tekton.dev/cancel-in-progresssetting does not ensure that only one copy of the pipeline run is executing at any time. -
To enable
cancellation-in-progressfor all default pipeline runs, use theenable-cancel-in-progress-on-pull-requestsand theenable-cancel-in-progress-on-pushsettings. These settings are available in theplatforms.openshift.pipelinesAsCode.settingsspec of theTektonConfigcustom resource (CR) configure Pipelines as Code.