Delegated Analysis Configuration

Delegated analysis configuration allows private repositories within an organization to specify another repository within the same organization to be used as its configuration repository. This can be useful for large organizations as it allows for centralized configurations.

Assigning a delegated configuration repository is done via an API call, which can be scripted for updating a large number of repos at once.

📘

Note

This attribute is set at the repository level, rather than the organization level, to support multiple configuration repositories within an organization (for instance, one for each language).

Show me how

  1. Create a configuration repository within your VCS. Note that all files in this repository will be copied and merged as part of the analysis so this should not contain any non-configuration files. By copying all files, this supports not just .codeclimate.yml files, but any plugin-specific configuration files.

📘

In-App Configurations

This feature does not currently support delegating to in-app configurations (ones configured on the repository settings page). It is targeted toward the advanced configuration options provided by the configuration files.

  1. Create your Code Climate organization. This can be done by adding one of the repos in steps (3) or (4). Note the account id, which can be found via the URL of the account dashboard page.

  2. Add your configuration repository to Code Climate. Note the repository id, which can be found via the URL of the repo overview page.

  3. Add additional repositories to Code Climate. For each repository that should be assigned a delegated configuration repo, note its repository id. This can be done via the API (GET /orgs/:org_id/repos) or visiting the individual repo overview pages.

  4. For each repository, construct an API request to assign the delegated configuration repository. Please see our API documentation for details on authorization. Note: To assign a delegated configuration to a repo, you must be an Admin of the repo on GitHub.

# note: to remove a delegated configuration repository,
# pass the setting without a value
# --data "data[attributes][delegated_config_repo_id]"

curl \
  -H "Accept: application/vnd.api+json" \
  -H "Authorization: Token token={TOKEN}" \
  -X PUT \
  --data "data[attributes][delegated_config_repo_id]=<CONFIG_REPO_ID>"
  https://api.codeclimate.com/v1/orgs/{ACCOUNT_ID}/repos/{REPO_ID}
  1. Once assigned, future builds for the repository will:
    • Clone the repository
    • Clone the delegated configuration repository at the sha for the latest default branch build
    • Copy all files from the delegated configuration repository into the repository workspace, overwriting if necessary, as if they had been checked in to the repository
    • Run analysis as normal

Once enabled, you will see an additional step on the build page:

1108

In addition, a banner will be displayed on the analysis configuration settings indicating a delegated configuration repository has been configured:

1163