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.
YOUR DEPLOYMENT JOURNEY
- You have gained the necessary resource access and permissions required for deployment.
- You have created a Semgrep account and organization.
- For GitHub and GitLab users: You have connected your source code manager.
- Optionally, you have set up SSO.
- AppVeyor
- Bamboo
- Bitrise
- Buildbot
- Codeship
- Codefresh
- Drone CI
- Nomad
- Semaphore
- TeamCity CI
- Travis CI
General steps
The following steps provide an overview of the process. View the succeeding sections for detailed instructions.Create a CI job that runs Semgrep. This step is typically achieved by committing a CI configuration file. The syntax of the configuration file depends on your CI provider.
The CI job can automatically start to run depending on your configuration. If the job does not start, run the job through the CI provider’s interface or by committing code.
Semgrep detects the
SEMGREP_APP_TOKEN, sends it to Semgrep AppSec Platform for verification, and if verified, sends findings to Semgrep AppSec Platform.Create a SEMGREP_APP_TOKEN
To create aSEMGREP_APP_TOKEN, follow these steps:
Sign in to Semgrep AppSec Platform.
Click Settings > Tokens.
Create a Semgrep CI job
Add Semgrep to your CI pipeline. Do either of the following:
i. Reference or add the Semgrep Docker image. This is the recommended method.
ii. Add
i. Reference or add the Semgrep Docker image. This is the recommended method.
ii. Add
pipx install semgrep (or uv tool install semgrep if you use uv) into your configuration file as a step or command, depending on your CI provider’s syntax. See the Python Packaging guide for more on installing standalone Python CLI tools.Add Semgrep through the Docker image.
Add Semgrep through the Docker image.
Add Semgrep by installing it.
Add Semgrep by installing it.
Run the job
Depending on your CI provider and configuration, the job runs automatically. Otherwise, trigger the job by committing code or opening a PR or MR.Verify the connection
To verify that your Semgrep CI job is connected to Semgrep AppSec Platform:Go to your Semgrep AppSec Platform Projects page.
Troubleshoot your CI job
Semgrep attempts to automatically detect certain CI values, such as your repository’s name and URL. These values are used to provide context to findings in Semgrep AppSec Platform and hyperlinks to the code that generated the finding. Refer to the following table for common issues and the corresponding environment variables you can set to fix them:| Issue | Environment variable to set | Affected CI providers |
|---|---|---|
| Can’t establish a connection to Semgrep AppSec Platform. | SEMGREP_APP_TOKEN | Must be set for all CI providers. |
| Semgrep doesn’t scan your PRs or MRs. | SEMGREP_BASELINE_REF | Required for CI providers except GitHub Actions or GitLab CI/CD. |
| Can’t click hyperlinks to your repository from Semgrep AppSec Platform, nor can Semgrep AppSec Platform create PR or MR comments. | SEMGREP_REPO_NAME | Set these environment variables as needed to troubleshoot broken links for any CI provider except GitHub Actions and GitLab CI/CD. |
| Can’t click hyperlinks to your repository from Semgrep AppSec Platform, nor can Semgrep AppSec Platform create PR or MR comments. | SEMGREP_REPO_URL | Set these environment variables as needed to troubleshoot broken links for any CI provider except GitHub Actions and GitLab CI/CD. |
| Can’t click hyperlinks to your repository from Semgrep AppSec Platform, nor can Semgrep AppSec Platform create PR or MR comments. | SEMGREP_BRANCH | Set these environment variables as needed to troubleshoot broken links for any CI provider except GitHub Actions and GitLab CI/CD. |
| Can’t click hyperlinks to your repository from Semgrep AppSec Platform, nor can Semgrep AppSec Platform create PR or MR comments. | SEMGREP_JOB_URL | Set these environment variables as needed to troubleshoot broken links for any CI provider except GitHub Actions and GitLab CI/CD. |
| Can’t click hyperlinks to your repository from Semgrep AppSec Platform, nor can Semgrep AppSec Platform create PR or MR comments. | SEMGREP_COMMIT | Set these environment variables as needed to troubleshoot broken links for any CI provider except GitHub Actions and GitLab CI/CD. |
| Can’t click hyperlinks to your repository from Semgrep AppSec Platform, nor can Semgrep AppSec Platform create PR or MR comments. | SEMGREP_PR_ID | Required to enable hyperlinks for Azure Pipelines. |
Data collected by Semgrep AppSec Platform
When running in CI, Semgrep runs fully in the CI build environment. Unless you have explicitly granted code access to Semgrep, your code is not sent anywhere.- Semgrep AppSec Platform collects findings, which includes the line number of the code match, but not the code. It is hashed using a one-way hashing function.
- Findings data is used to generate line-specific hyperlinks to your source code management system and support other Semgrep functions.
Next steps
You’ve set up Semgrep to scan in your repository and send findings after each scan. Your core deployment is almost complete. Remaining steps include:- Optional: Customize your CI job.
- For software composition analysis (SCA) scans using Jenkins or Maven: Set up SCA scans for your infrastructure.
- Set up diff-aware scanning for feature branches (non-trunk branches) when a pull request or merge request is open. This is a prerequisite to receiving PR or MR comments. See Set up diff-aware scans.
- Set up PR or MR comments, which post findings to developers in your SCM. This involves developers in the security process as active participants. See PR or MR comments for next steps.