Overview
Pipelines-as-Code automatically creates authentication credentials for accessing private Git repositories. When a PipelineRun is triggered, PAC generates a temporary secret containing Git credentials that can be used by thegit-clone task and other tasks requiring repository access.
How It Works
When PAC creates a PipelineRun, it automatically generates a secret with the following format:.gitconfig: Git configuration file with authentication settings.git-credentials: Git credentials file with the access tokengit-provider-token: Raw token for direct API access
- GitHub App installation (when using GitHub App authentication)
- Git provider secret (when using webhook-based authentication)
The secret has an
ownerReference to the PipelineRun, so it’s automatically deleted when you delete the PipelineRun.Disabling Auto-Creation
To disable automatic secret creation, configure thesecret-auto-create setting in the pipelines-as-code ConfigMap:
Using the Generated Secret
With git-clone Task
The git-clone task expects a workspace namedbasic-auth:
Template variable that expands to the name of the auto-generated authentication secret.
Complete Example with Embedded Pipeline
Using Token for Git Provider API Operations
The generated secret includes agit-provider-token key for direct API access:
The token has the same permissions as the GitHub App installation or the webhook token, scoped to the repository.
Token Scoping
By default, the GitHub App token is scoped only to the repository where the event originated. To extend access to additional repositories, see Repository CRD Token Scoping.Fetching Remote Tasks from Private Repositories
Using Tekton Remote Resolution
To fetch tasks from private GitHub repositories using Tekton’s remote resolution:Using PAC Resolver
Pipelines-as-Code provides its own resolver for fetching tasks from private repositories:Authentication Methods
GitHub App (Recommended)
When using GitHub App authentication, PAC automatically:- Generates installation tokens for the repository
- Configures Git credentials
- Scopes access to the repository (and optionally additional repos)
Webhook with Token
For webhook-based providers (GitLab, Bitbucket, Gitea/Forgejo), provide a token:Git provider type. Supported values:
github- GitHub.com or GitHub Enterprisegitlab- GitLab.com or self-hostedbitbucket-cloud- Bitbucket Cloudbitbucket-datacenter- Bitbucket Data Centergitea- Gitea instancesforgejo- Forgejo instances
Secret Lifecycle
Auto-Deletion
The generated secret is automatically deleted when:- The PipelineRun is deleted
- The PipelineRun’s retention policy triggers cleanup
Manual Management
If you disable auto-creation, create secrets manually:Troubleshooting
Authentication Failed
Authentication Failed
Symptoms:
fatal: Authentication failederrorsPermission deniedwhen cloning
- Verify the GitHub App is installed on the repository
- Check that the webhook token has correct permissions
- Ensure the Repository CR URL matches the actual repository
- For GitHub Enterprise, verify the API URL is correct
Secret Not Found
Secret Not Found
Symptoms:
secret "{{ git_auth_secret }}" not found- Template variable not expanded
- Check that
secret-auto-createis not set tofalse - Verify the PipelineRun was created by PAC, not manually
- Ensure you’re using the exact template syntax:
{{ git_auth_secret }}
Cannot Access Additional Private Repositories
Cannot Access Additional Private Repositories
Symptoms:
- Can clone the main repo but not referenced repos
- Task resolution fails for private remote tasks
- Configure token scoping in the Repository CR
- Add repositories to
github_app_token_scope_repos - Verify the GitHub App is installed on all required repos
Token Expired or Invalid
Token Expired or Invalid
Symptoms:
401 UnauthorizedAPI responses- Authentication works initially then fails
- GitHub App tokens are valid for 1 hour - this should be sufficient for most pipelines
- For webhook tokens, verify the token hasn’t been revoked
- Regenerate webhook tokens if needed
- Check token permissions/scopes are sufficient
Security Best Practices
- Use GitHub App: Prefer GitHub App authentication over personal access tokens
- Scope Tokens: Only grant access to repositories that are actually needed
- Short-lived Tokens: GitHub App tokens expire after 1 hour automatically
- Audit Access: Review which repositories can access GitHub App tokens
- Cleanup: Let PAC auto-delete secrets - don’t disable unless necessary
- Fine-grained PATs: If using webhook auth, use fine-grained personal access tokens with minimal scopes
Examples
Multi-Repo Build with Private Dependencies
Multi-Repo Build with Private Dependencies
Private Task Resolution
Private Task Resolution
See Also
- Repository CRD - Repository configuration reference
- Resolver - Fetching remote tasks and pipelines
- Authoring PipelineRuns - Template variables reference
- GitHub App Installation - Setting up GitHub App authentication