Add ci-env read subcommand to print extracted CI env info#2123
Merged
Bit-Doctor merged 3 commits intomasterfrom Feb 20, 2026
Merged
Add ci-env read subcommand to print extracted CI env info#2123Bit-Doctor merged 3 commits intomasterfrom
ci-env read subcommand to print extracted CI env info#2123Bit-Doctor merged 3 commits intomasterfrom
Conversation
8675f0d to
cc182bd
Compare
|
✅ Tests 🎉 All green!❄️ No new flaky tests detected 🔗 Commit SHA: 509ff2d | Docs | Datadog PR Page | Was this helpful? Give us feedback! |
Bit-Doctor
commented
Feb 19, 2026
Drarig29
reviewed
Feb 20, 2026
Contributor
Drarig29
left a comment
There was a problem hiding this comment.
Mainly nits, otherwise it looks good!
Comment on lines
+157
to
+163
| examples: [ | ||
| ['Set variables in current shell', 'eval "$(datadog-ci ci-env read)"'], | ||
| ['Save as .env file for Docker', 'datadog-ci ci-env read > .env'], | ||
| ['Use with shell scripts', 'datadog-ci ci-env read > ci.env && source ci.env'], | ||
| ['Get JSON output', 'datadog-ci ci-env read --format json'], | ||
| ['Get Datadog tags format', 'datadog-ci ci-env read --format tags'], | ||
| ], |
Contributor
There was a problem hiding this comment.
I tested all those examples locally with export GITHUB_ACTION=1; export GITHUB_JOB=abc;, and it works properly 👍
packages/base/src/commands/ci-env/__tests__/read-ci-env.test.ts
Outdated
Show resolved
Hide resolved
ci-env read subcommand to print extracted CI env info
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why?
This PR adds a new
ci-env readcommand that extracts CI-specific environment variables from various CI providers (GitHub Actions, GitLab CI, CircleCI, Travis CI, Jenkins, etc.) and outputs them in a normalizedDD_CI_*andDD_GIT_*format.Why: CI environment variables are inconsistent across providers (e.g.,
TRAVIS_JOB_WEB_URL,GITHUB_RUN_ID,CIRCLE_BUILD_NUM). This command normalizes them into a consistent format that can be:Supports three output formats:
bash(default):.envfile format -DD_CI_JOB_NAME='deploy-prod'json: JSON object for programmatic processingtags: Datadog internal tag format -ci.job.name:"deploy-prod"How?
getCISpanTags(),getUserCISpanTags(), andgetUserGitSpanTags()functions fromhelpers/ci.tsandhelpers/user-provided-git.tsTAG_TO_ENV_VAR) to translate internal tag keys (e.g.,ci.job.url) to environment variables (e.g.,DD_CI_JOB_URL)escapeBashValue(): Single-quote escaping to prevent variable expansion/command injectionescapeTagValue(): Double-quote and backslash escaping for tag formatgetCISpanTags()Review checklist