Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.semgrep.dev/llms.txt

Use this file to discover all available pages before exploring further.

When working with a CI provider, you can set Semgrep to run diff-aware scans as well as full scans. Diff-aware scans run on your code before and after some baseline, and only report findings newly introduced in the commits after that baseline.
To add this configuration in Azure Pipelines, follow the general instructions provided in Sample CI configurations: Azure Pipelines. If your repository’s default branch is not main, change the references to main to the name of your default branch.
steps:
- checkout: self
  clean: true
  fetchDepth: 20
persistCredentials: true
- script: |
    python -m pip install --upgrade pipx
    pipx install semgrep
    if [ $(System.PullRequest.PullRequestId) -ge 0 ]; then
      echo "Pull Request Scan from branch: $(Build.SourceBranchName)"
      git fetch origin main:origin/main
      export SEMGREP_PR_ID=$(System.PullRequest.PullRequestId)
      export SEMGREP_BASELINE_REF='origin/main'
      semgrep ci
If you are running both full and diff-aware scans for the repository, you can use if clauses or define separate templates for full scans and diff-aware scans in Azure Pipelines. Diff-aware scans require the use of the SEMGREP_PR_ID and SEMGREP_BASELINE_REF variables, while full scans do not. Full scans are typically run on the condition if [ $(Build.SourceBranchName) = "main" ].