This page is not yet available in Spanish. We are working on its translation. If you have any questions or feedback about our current translation project, feel free to reach out to us!
CI Visibility is not available for the selected site ().
Custom commands provide a way to trace individual commands in your CI pipelines, allowing you to measure the time your command takes without taking into account any setup or teardown actions that the job might have (for example, downloading Docker images or waiting for an available node in a Kubernetes-based infrastructure). These spans appear as part of the pipeline’s trace:
Compatibility
Custom commands work with the following CI providers:
GitHub.com (SaaS) with datadog-ci CLI >= 2.40. For sending custom commands in GitHub Actions, see Trace a command.
GitLab (SaaS or self-hosted >= 14.1) with datadog-ci CLI >= 2.40.
Jenkins with the Datadog plugin >= v3.2.0
CircleCI
Azure DevOps Pipelines with datadog-ci CLI >= 2.40.
AWS Codepipeline with datadog-ci CLI >= 2.40. Follow Adding custom commands to set up custom commands in AWS Codepipeline.
Buildkite with datadog-ci CLI >= 2.40.
Install the Datadog CI CLI
Install the datadog-ci (>=v0.17.0) CLI globally using npm:
npm install -g @datadog/datadog-ci
Trace a command
To trace a command, run:
datadog-ci trace [--name <name>] -- <command>
Specify a valid Datadog API key in the DATADOG_API_KEY environment variable. For example:
CI Visibility is not available in the selected site ().
Configuration settings
These options are available for the datadog-ci trace command:
--name
Display name of the custom command. Default: same value as <command> Example: Wait for DB to be reachable
--tags
Key-value pairs in the form key:value to be attached to the custom command (the --tags parameter can be specified multiple times). When specifying tags using DD_TAGS, separate them using commas (for example, team:backend,priority:high). Environment variable: DD_TAGS Default: (none) Example: team:backend Note: Tags specified using --tags and with the DD_TAGS environment variable are merged. If the same key appears in both --tags and DD_TAGS, the value in the environment variable DD_TAGS takes precedence.
--measures
Key-value pairs in the form key:value to be attached to the custom command as numerical values (the --measures parameter can be specified multiple times). (Requires datadog-ci >=v2.35.0) Default: (none) Example: size:1024
--no-fail
Prevents datadog-ci from failing even if run in an unsupported CI provider. In this case, the command is run and nothing is reported to Datadog. Default: false
--dry-run
Prevents datadog-ci from sending the custom span to Datadog. All other checks are performed. Default: false
Positional arguments
The command that is launched and traced.
The following environment variables are supported:
DATADOG_API_KEY (Required)
Datadog API key used to authenticate the requests. Default: (none)
Additionally, configure the Datadog site to use the selected one ():
DATADOG_SITE
The Datadog site to upload results to. Default: datadoghq.com Selected site:
Trace a command in GitHub Actions
If the job name does not match the entry defined in the workflow configuration file (the GitHub job ID),
the DD_GITHUB_JOB_NAME environment variable needs to be exposed, pointing to the job name. For example:
If the matrix strategy is used, several job names are generated by GitHub by adding the matrix values at the end of the job name, within parenthesis. The DD_GITHUB_JOB_NAME environment variable should then be conditional on the matrix values:
The size limit is approximately 4MB. The most common cause for this error is extremely large tags.
Use the --dry-run option to see the traced command’s contents before sending it to Datadog.