1.2. Pipelines as Code concepts
Pipelines as Code interacts with your Git repository provider. To use Pipelines as Code, you must first configure this integration.
You can use Pipelines as Code with any number of repositories within your Git repository provider. For each repository, you must create a Repository custom resource (CR) within an OpenShift Container Platform namespace that you control. This CR contains information that Pipelines as Code can use to access this repository.
Pipelines as Code starts the pipeline runs for a repository within the namespace in which the Repository CR for this repository is located.
Inside your Git repository, you must create a .tekton directory and store pipeline run definitions as YAML files in this directory. Each pipeline run that you define must include annotations that determine the events that must trigger this pipeline run.
The definition can reference other YAML files in the same directory. For example, you can define a pipeline in a separate YAML file and refer to this pipeline in the pipeline run file. You can also use annotations in the pipeline run definition to reference task and pipeline resources from Tekton Hub, from HTTP locations, and from other paths in your directory. You can use special variables in the definition to reference execution context, such as the name of the branch.
When a matching event happens, Pipelines as Code creates a PipelineRun CR based on the definition that you provided in the repository. Creating a PipelineRun CR triggers execution of the pipeline that is defined in the pipeline run.
Pipelines as Code uses the Pipelines as Code resolver to create the PipelineRun CR based on your definition. The Pipelines as Code resolver retrieves all of the resources that you referenced by using annotations and adds them to the PipelineRun CR. If the Pipelines as Code resolver fails to retrieve any referenced resource, Pipelines as Code logs an error and does not create a pipeline run.
Pipelines as Code also replaces dynamic variables in your pipeline run definition with their values.
By default, when creating a PipelineRun CR for a pull request or push event, Pipelines as Code uses the definitions from the .tekton directory of the source branch of the pull request or push event. If the pull request or push event modifies the .tekton directory, Pipelines as Code uses the modified version.
You can define the pipelinerun_provenance: "default_branch" setting in the Repository CR to change this behaviour. If you specify this setting, Pipelines as Code always uses definitions from the .tekton directory of the default branch configured on the Git repository provider, such as main, master, or trunk.