This feature is only available on Chainloop’s platform paid plans.
CHAINLOOP_RUNNER_CONTEXT material. This information includes the basic information about your CI/CD environment.
The Chainloop CLI Enterprise Edition (CLI EE) enables automatic gathering of detailed runner context by collecting
repository security configuration data directly from your CI/CD environment. This feature captures:
- Branch protection settings: push restrictions, history and deletion controls
- Pull request protection settings: review requirements, dismissal rules, and conversation resolution policies
- Commit protection settings: signing requirements
- Repository access settings: teams with repository access and their members, collaborators with their effective roles, and custom repository roles
Gathering Runner Context
Gathering the CI/CD runner context requires a few steps:Installing Chainloop CLI Enterprise Edition (CLI EE)
The first step is to install Chainloop CLI EE. You can learn more about installing Chainloop CLI EE here or just run the following command:Create the Access Token
The second step is to create an access token for GitHub or GitLab. In order to gather the comprehensive runner context, Chainloop CLI EE requires an access token with the appropriate access level. Depending on the CI/CD platform of your choice, the access token will have different requirements. The token is only used bychainloop gather-runner-context on the runner to read your repository settings. It stays on the runner and is not sent to Chainloop.
- GitHub
- GitLab
We support two authentication methods for gathering runner context:For Enterprise GitHub accounts: You must use a Classic Personal Access Token (not a fine-grained token) with the additional
Enterprise GitHub AccountsIf you have an Enterprise GitHub account, you must create your GitHub Application at the enterprise level (not just at the organization level). Additionally:
- Create the GitHub App in your Enterprise settings:
Enterprise settings->Developer settings->GitHub Apps->New GitHub App - Configure permissions at the enterprise level as described below
- Install the app on the specific organizations and repositories within your enterprise
- When using Personal Access Tokens (Method 2), you must use a Classic PAT (not fine-grained tokens) with the
read:enterprisescope - Set the
GITHUB_ENTERPRISEenvironment variable to your enterprise slug when running the gatherer
Method 1: Custom GitHub Application (Recommended)
For enterprise environments, you can create a custom GitHub Application to retrieve the data. This approach provides better security and management capabilities.Steps to register the GitHub Application:- Register a new GitHub Application in your Organization or Account profile, under Developer settings -> GitHub Apps -> New GitHub App
- Add a Homepage URL since it’s a required parameter
- Uncheck the Expire user authorization tokens checkbox
- Uncheck the Webhook active checkbox
- Select the following permissions:
- Repository:
Administration: read and writeContents: read-only
- Organization:
Members: read-onlyAdministration: read-onlyCustom Organization Roles: read-onlyCustom Repository Roles: read-only
- Enterprise (for enterprise accounts only, in addition to the above):
Custom Enterprise Roles: read-onlyCustom Organization Roles: read-only
- Repository:
Why these permissions are required:
- Repository Administration (read and write): Write permission is required by GitHub’s API to access security-sensitive ruleset configuration details needed for policy enforcement. The gatherer only reads configuration data and does not modify any repository settings.
- Repository Contents (read-only): Required to read repository metadata and basic information
- Organization Members (read-only): Required to fetch team member information for teams with repository access
- Organization Administration (read-only): Required to fetch all organization teams and determine which teams have access to specific repositories. This is particularly important for GitHub Apps, as they need this permission to discover organization-level team grants that aren’t visible through repository-specific API endpoints.
- Custom Organization/Repository Roles (read-only): Required to resolve custom role names to their actual permissions and base roles
- Enterprise Custom Roles (read-only) (Enterprise accounts only): Required to retrieve enterprise-level custom roles that may be assigned to teams or users
- Click on This enterprise (for enterprise accounts) or select Any account (for non-enterprise accounts), depending on your desired installation scope
- Once registered, click on Generate a private key. This will download a private key file - store it securely
- Copy the App ID
- To install the GitHub App on specific repositories or the entire organization, go to Developer settings -> GitHub Apps -> Your new App and click on Edit. Once the app is loaded, click on Install App in the left sidebar and follow the installation steps.
- Store the App ID as a GitHub Actions variable (e.g.,
APP_ID) - Store the private key as a GitHub Actions secret (e.g.,
APP_PRIVATE_KEY)
Method 2: Personal Access Token (PAT)
Create a personal access token with the following permissions:Only select repositories- select the repository you want to gather context data from- Repository permissions:
Administration-Access: Read and writeContents-Access: Read-only
- Organization permissions:
Members-Access: Read-onlyAdministration-Access: Read-only
Why these permissions are required:Repository Administration (Read and write): Write permission is required by GitHub’s API to access security-sensitive ruleset configuration details needed for policy enforcement. The gatherer only reads configuration data and does not modify any repository settings.Organization Administration (Read-only): Essential for comprehensive team access discovery, allowing the gatherer to fetch all organization teams and determine which have access to your repositories. Without this permission, only teams with explicit repository access grants will be visible.
read:enterprise scope. Fine-grained tokens do not support enterprise-level API endpoints.Once generated, store the personal access token in the CI/CD secrets (e.g., ADMIN_PERSONAL_ACCESS_TOKEN).Gather Runner Context
The third step is to gather the runner context data. The approach differs based on your CI/CD platform and authentication method:- GitHub - Using GitHub Application
- GitHub - Using Personal Access Token
- GitLab
When using a GitHub Application, you need to generate a token from the app credentials first, then use it with the Chainloop CLI. The following action allows you to retrieveThe key difference is using the For Enterprise GitHub accounts: Don’t forget to set the
actions/create-github-app-token action to generate a temporary token from your GitHub App credentials, which is then passed to the chainloop gather-runner-context command by using the ${{ steps.generate-token.outputs.token }} expression.GITHUB_ENTERPRISE environment variable:Choose the Branches to Collect
Use--branches to limit the collected data to the branches you protect, for example:
* matches any characters except /, so release/* matches release/1.0 but not release/1.0/hotfix. ** also crosses /, so release/** matches both. The branches input of the branch protection policies uses the same rule.
Related flags: --tags and --max-tags (default 15) for tag data, and --fetch-contributors to collect contributors.
Add the Runner Context to the Attestation
The fourth step is to add the runner context to the attestation. This can be done by adding the following command to your CI/CD pipeline, afterchainloop gather-runner-context has written runner-context.json:
runner-context.
And that’s it, you are ready. You can now use the gathered runner context with the branch protection policies.
Skipped policies
When the collector cannot read some data, it records an error in the runner context and the policies that need that data are skipped instead of passing or failing. The skip reason says what to change in the token used bychainloop gather-runner-context:
Classic branch protection that cannot be read
The GitHub branch and pull request policies do not skip the whole repository when the collector cannot read classic branch protection. This happens when the token lacks theAdministration permission or GitHub returns a temporary error. The policies judge each branch on its own:
- A branch passes when its active rulesets alone pass the check.
- A branch whose classic rule was read is judged as usual.
- Any other branch cannot be verified. If no branch fails for certain, the policy is skipped and the skip reason names the branches that could not be verified. If a branch fails, the policy reports only the failures.
