Advanced Repository Configuration
This guide is for regular users who need advanced Repository CR configurations, such as concurrency limits, source branch settings, and custom parameter expansion.
This guide explains advanced configuration options for Repository Custom Resources, including:
- Global Repository CR for automatic configuration inheritance (Tech Preview)
- Concurrency limits
- Source branch configuration
- Custom parameter expansion
TOC
Prerequisites
- PAC component deployed and running
- A Repository CR created (see Configure Repository)
- Cluster administrator or namespace-level permissions
Creating a Global Repository CR
The global Repository CR feature is a Technology Preview feature that provides automatic configuration inheritance for all Repository CRs.
Alternatively, you can create a global Repository CR in the namespace where PAC is installed (typically tekton-pipelines or configured via targetNamespace in the OpenShiftPipelinesAsCode CR). If you create a Repository CR named pipelines-as-code in this namespace, the settings you specify in it will be automatically applied to all Repository CRs you create.
Key Points:
- Name: Must be exactly
pipelines-as-code - Namespace: Must be in the PAC installation namespace (e.g.,
tekton-pipelines) - Auto-apply: Settings automatically apply to all Repository CRs
- Tech Preview: This is a Technology Preview feature
Example: Global Repository CR
Create a global Repository CR in the PAC namespace:
Apply the CR:
Behavior:
- All Repository CRs you create will inherit these
git_providersettings - Individual Repository CRs can override these settings if needed
- You still need to specify
urland other repository-specific settings in each Repository CR
Example: Using Global Settings
With the global CR above, you can create individual Repository CRs with minimal configuration:
Setting Concurrency Limits
Concurrency limits help prevent resource exhaustion when many events trigger pipelines simultaneously. You can set the maximum number of concurrent PipelineRuns that can run for a repository.
Configure Concurrency Limit
Edit your Repository CR to add the concurrency_limit field:
Important:
- The minimum value is
1 - If not specified, there is no limit on concurrent PipelineRuns
- When the limit is reached, new events will queue until a PipelineRun completes
Example Use Cases
High-traffic repository: Limit concurrent runs to prevent cluster overload:
Resource-intensive pipelines: Limit to ensure sufficient resources per run:
No limit (default): Allow unlimited concurrent runs:
Verify Concurrency Limit
Check the Repository CR:
Example output (abbreviated):
Monitor running PipelineRuns:
Example output:
Changing the Source Branch for Pipeline Definition
By default, Pipelines-as-Code fetches the PipelineRun definition from the branch where the event has been triggered (for example, the branch of the push or pull request).
You can change this behavior by using the spec.settings.pipelinerun_provenance field in the Repository custom resource. This setting controls from which branch the PipelineRun definition is fetched.
Configure PipelineRun definition source
Supported values for pipelinerun_provenance:
source: The default behavior. The PipelineRun definition is fetched from the branch where the event has been triggered.default_branch: The PipelineRun definition is fetched from the repository default branch as configured on the Git provider (for examplemain,master, ortrunk).
Security Benefits
Letting the user specify the provenance of the PipelineRun definition to the default branch is another layer of security. It ensures that only the user who has the right to merge commits to the default branch can change the PipelineRun definition and gain access to the infrastructure.
- Prevents malicious pipeline changes: Pipeline definitions must be merged to the default branch before they can be executed.
- Enforces review process: All pipeline changes go through the standard merge/review process.
- Consistent pipeline behavior: All runs use the same pipeline definitions from the default branch.
Configuration comparison
Note: According to the Red Hat OpenShift Pipelines documentation, the default_branch setting is recommended as a security measure to ensure maximum validation of pipeline changes during the merge review process.
Custom Parameter Expansion
You can define custom parameters in the Repository CR that will be expanded in all PipelineRuns created for that repository. This is useful for setting common values across all pipelines.
Define Custom Parameters
Add parameters to the Repository CR spec.params field:
Use Custom Parameters in Pipelines
Important: Repository CR parameters use the PAC variable syntax {{ param }}, not Tekton's $(params.param) syntax.
-
PAC variables (
{{ variable }}): PAC replaces these before creating the PipelineRun. This includes:- Repository CR parameters from
spec.params(e.g.,{{ environment }},{{ cluster-name }}) - PAC built-in variables (e.g.,
{{ revision }},{{ repo_url }},{{ source_branch }})
- Repository CR parameters from
-
Tekton parameters (
$(params.param)): Tekton resolves these during PipelineRun execution. These reference the PipelineRun's ownspec.params.
Reference Repository CR parameters in your PipelineRun definitions using PAC variable syntax:
How it works:
- Before PipelineRun creation: PAC replaces all
{{ variable }}syntax with actual values from Repository CR params and built-in variables - PipelineRun creation: PAC creates the PipelineRun with all variables already replaced
- During execution: Tekton resolves
$(params.xxx)syntax by reading from the PipelineRun'sspec.params
Example transformation:
- In your Git repo:
value: "{{ environment }}" - PAC replaces it:
value: "production"(from Repository CR param) - PipelineRun created with:
- name: environment/value: "production" - Task scripts use:
$(params.environment)→ Tekton resolves to"production"
Parameter Precedence
Parameters are expanded in the following order (highest to lowest precedence):
- PipelineRun params: Parameters explicitly defined in the PipelineRun
- Repository params: Parameters defined in the Repository CR
- Dynamic variables: PAC dynamic variables (e.g.,
{{ revision }},{{ repo_url }})
Example: Environment-Specific Configuration
Configure different environments using Repository params:
Production Repository:
Staging Repository:
Both repositories can use the same pipeline definition, with parameters automatically filled from the Repository CR.
Combining Advanced Features
You can combine all advanced features in a single Repository CR:
Best Practices
1. Concurrency Limits
- Set appropriate limits: Consider your cluster resources and pipeline resource requirements
- Monitor usage: Watch for queued events when limits are too low
- Adjust dynamically: Increase limits for high-traffic periods, decrease for resource conservation
2. Source Branch Configuration
- Use stable branches: Fetch pipeline definitions from stable branches (e.g.,
main) - Test pipeline changes: Test pipeline changes in feature branches before merging to the source branch
- Document changes: Clearly document which branch contains pipeline definitions
3. Custom Parameters
- Use meaningful names: Choose clear, descriptive parameter names
- Keep values simple: Use simple string values for parameters
- Document parameters: Document what each parameter does and when it's used
- Avoid secrets: Don't store secrets in Repository params; use Kubernetes Secrets instead
Troubleshooting
Concurrency Limit Not Working
-
Verify the limit is set:
Example output:
-
Check for queued events: Look for events that are waiting for PipelineRuns to complete
-
Verify PAC controller logs:
Example output:
Parameters Not Expanding
-
Verify parameters are defined:
-
Check parameter syntax: Ensure you're using
{{ param }}syntax to reference Repository CR parameters, not$(params.param) -
Verify variable replacement: Check the created PipelineRun to see if PAC replaced the variables:
-
Review PipelineRun: Check if parameters are being overridden in the PipelineRun definition
Next Steps
- Configure Repository - Basic repository setup
- Maintain Pipeline Code - Pipeline definition guide
- Manage PipelineRuns - PipelineRun management
- Common Issues - Troubleshooting guide