Skip to main content
Version: Config V1 (legacy)

Azure DevOps - Scan your source code for feature flags

This section describes how to use the ConfigCat CLI in Azure DevOps Pipelines to automatically scan your source code for feature flag and setting usages and upload the found code references to ConfigCat.

Setup

  1. Create a new ConfigCat Management API credential and store its values in Azure DevOps Pipeline Variables with the following names: CONFIGCAT_API_USER, CONFIGCAT_API_PASS.

    Azure secrets
  2. Get your selected Config's ID.

  3. Create a new or open your existing azure-pipelines.yml file, and add the following job to your jobs definition. Don't forget to replace the PASTE-YOUR-CONFIG-ID-HERE value with your actual Config ID.

    - job: configcat_scan_and_upload
    container: configcat/cli:azure-devops-1.9.2
    pool:
    vmImage: ubuntu-latest
    steps:
    - checkout: self
    persistCredentials: true
    - script: configcat scan $(Build.Repository.LocalPath)
    --config-id=PASTE-YOUR-CONFIG-ID-HERE
    --repo=$(Build.Repository.Name)
    --branch=$(Build.SourceBranchName)
    --file-url-template="$(Build.Repository.Uri)?path={filePath}&version=GC{commitHash}&line={lineNumber}&lineStartColumn=1&lineEndColumn=1"
    --commit-url-template="$(Build.Repository.Uri)/commit/{commitHash}"
    --runner="ConfigCat Azure DevOps Job"
    --upload
    --non-interactive
    name: scan_repository
    env:
    CONFIGCAT_API_PASS: $(CONFIGCAT_API_PASS)
    CONFIGCAT_API_USER: $(CONFIGCAT_API_USER)
info

If you are using a different VCS than Azure DevOps' Git, you should set the --file-url-template and --commit-url-template according to your VCS provider.

  1. Commit & push your changes.

Scan reports are uploaded for each branch of your repository that triggers the job.