Code Analysis is not available for the site.
Try the Beta!
Code Analysis is in public beta.
Overview
If you don’t use CircleCI Orbs or GitHub Actions, you can run the Datadog CLI directly in your CI pipeline platform.
Prerequisites:
Configure the following environment variables:
Name | Description | Required | Default |
---|
DD_API_KEY | Your Datadog API key. This key is created by your Datadog organization and should be stored as a secret. | Yes | |
DD_APP_KEY | Your Datadog application key. This key is created by your Datadog organization and should be stored as a secret. | Yes | |
DD_SITE | The Datadog site to send information to. Your Datadog site is . | No | datadoghq.com |
Provide the following inputs:
Name | Description | Required | Default |
---|
service | The name of the service to tag the results with. | Yes | |
env | The environment to tag the results with. ci is a helpful value for this input. | No | none |
cpu_count | Set the number of CPUs used by the analyzer. Defaults to the number of CPUs available. | No | |
subdirectory | The subdirectory path the analysis should be limited to. The path is relative to the root directory of the repository. | No | |
Add a `--performance-statistics` flag to your static analysis command to get execution time statistics for analyzed files.
Select an analyzer for your architecture and OS:
Architecture | OS | Name | Link |
---|
aarch64 | Darwin | datadog-static-analyzer-aarch64-apple-darwin.zip | Download |
aarch64 | Linux | datadog-static-analyzer-aarch64-unknown-linux-gnu.zip | Download |
x86_64 | Darwin | datadog-static-analyzer-x86_64-apple-darwin.zip | Download |
x86_64 | Linux | datadog-static-analyzer-x86_64-unknown-linux-gnu.zip | Download |
x86_64 | Windows | datadog-static-analyzer-x86_64-pc-windows-msvc.zip | Download |
Add the following to your CI pipeline:
The following example uses the x86_64 Linux version of Datadog's static analyzer. If you're using a different OS or architecture, you should select it from the table above and update the DATADOG_STATIC_ANALYZER_URL value below. You can view all releases on our
GitHub Releases page.
# Set the Datadog site to send information to
export DD_SITE="datadoghq.com"
# Install dependencies
npm install -g @datadog/datadog-ci
# Download the latest Datadog static analyzer:
# https://github.com/DataDog/datadog-static-analyzer/releases
DATADOG_STATIC_ANALYZER_URL=https://github.com/DataDog/datadog-static-analyzer/releases/latest/download/datadog-static-analyzer-x86_64-unknown-linux-gnu.zip
curl -L $DATADOG_STATIC_ANALYZER_URL > /tmp/ddog-static-analyzer.zip
unzip /tmp/ddog-static-analyzer.zip -d /tmp
mv /tmp/datadog-static-analyzer /usr/local/datadog-static-analyzer
# Run Static Analysis
/usr/local/datadog-static-analyzer -i . -o /tmp/report.sarif -f sarif
# Upload results
datadog-ci sarif upload /tmp/report.sarif --service <service> --env <env>
Further Reading
Additional helpful documentation, links, and articles: