Contains helper commands related to CD Visibility.
The mark command specifies that a CI job executes a deployment.
datadog-ci deployment mark [--env] [--revision] [--service] [--is-rollback] [--tags] [--no-fail]For example:
datadog-ci deployment mark --env prod --service payment-service --revision v1.1.0 --tags team:backend --no-fail--envis the environment to which this deployment is performed. For example,prod.--revisionis the revision/version that is being deployed. For example,1.0.0orv123-456.--servicethe name of the service being deployed. For example,payment-service.--is-rollbackspecifies that the deployment is a rollback.--tagsis an array of key value pairs in the formatkey:value. These tags are added to the deployment event shown in Datadog.--no-fail(default:false) prevents the deployment command from failing if there are issues submitting the data.--dry-run(default:false): runs the command without sending requests. All other checks are performed.
Note: If you are using datadog-ci deployment mark, then you do not need to use this command, as the correlation is made automatically.
The correlate command connects a GitOps deployment with the CI pipeline of the application repository. Once they are connected, you can see in Datadog's UI which pipeline
triggered a deployment, and which deployments were triggered by a pipeline.
Important: This command does not work for every setup. Refer to the documentation for more details.
For example:
datadog-ci deployment correlate --provider argocd--provider(required): the CD provider name. Currently, the only supported CD provider isargocd.--config-repo: configuration repository URL where the kubernetes manifests are stored. If empty, the command tries to get it using the git commandgit ls-remote --get-url.--config-shas: a list of the Git commit SHAs of the configuration repository. If empty, the command tries to get all local commits using agit logcommand.--dry-run(default:false): prevents the command from sending any data to Datadog. All the other checks are still performed.
Note: This command replaces datadog-ci deployment correlate.
The correlate-image command connects an image generated on CI with a commit of the application repository. Then, when Datadog receives a deployment that deploys your image,
the deployment is correlated to the application commit. This allows for correlation between configuration and application repositories in GitOps scenarios.
Important: This command does not work for every setup. Refer to the documentation for more details.
For example:
datadog-ci deployment correlate-image --commit-sha c9c4e93346652f426c91a2c41364679698bc492f --repository-url https://github.com/DataDog/datadog-ci --image datadog-ci:sha@038d890a9c01bc90a634fafedbd1c2fcd05cd95f--commit-sha(required): Commit SHA to correlate with an image. Should be from the application repository.--repository-url(required): Repository URL for the commit SHA being correlated.--image(required): Image to correlate with the commit SHA.
The command also automatically collects CI environment variables from the CI job that built the image (when run inside a supported CI provider) and includes them in the request so Datadog can attribute the image to the pipeline and job that built it.
The gate command evaluates a Deployment Gate and exits with code 0 if the gate passed or 1 if the gate failed. Refer to the Deployment Gates documentation for more details.
datadog-ci deployment gate --service --env [--identifier] [--version] [--apm-primary-tag] [--config] [--timeout] [--fail-on-error]For example:
datadog-ci deployment gate --service payments-backend --env prod--service(required): Service name. For examplepayments-backend.--env(required): Environment name. For exampleprod.--identifier(default:default): Deployment Gate identifier. For example,pre.--version(required if your gate has faulty deployment detection rules): Version that is being deployed. For example,v1.0.3.--apm-primary-tag: APM primary tag (only for gates with faulty deployment detection rules). For example,region:us-central-1.--config: Path to a JSON file containing gate configuration. Use this to define inline rules without requiring a pre-created gate in Datadog. Refer to the setup documentation for more details.--timeout(default: 10800 = 3 hours): Maximum time to wait for the script execution in seconds. For example,3600.--fail-on-error(default:false): When false, the script will consider the gate as passed and exit with code 0 when timeout is reached or unexpected errors occur. Otherwise it will consider the gate failed and exit with code 1.
The command will exit with status 0 when the gate passes and status 1 otherwise.
Example configuration file:
{
"dryRun": false,
"rules": [
{
"type": "monitor",
"name": "error rate monitors",
"options": {
"query": "service:payments-backend env:prod",
"duration": 300
}
}
]
}DD_API_KEY(required): API key used to authenticate the requests.DD_APP_KEY(required forcorrelate-imageandgate): APP key used to authenticate the requests.DD_SITE: choose your Datadog site. For example, datadoghq.com or datadoghq.eu.
Additional helpful documentation, links, and articles: