deployment correlate-image: include ci_env in request payload#2328
deployment correlate-image: include ci_env in request payload#2328DaniFdz wants to merge 3 commits into
Conversation
Mirror the CI env collection logic from `deployment correlate` so that `deployment correlate-image` also sends `ci_env` (a map of CI span tags merged with provider-specific env vars). The backend will use this to derive pipeline_correlation_id and job_correlation_id for the image built by the CI job. Additive and backward-compatible: older CLI versions still work, the backend ignores `ci_env` until the dd-source companion lands.
🎉 All green!🧪 All tests passed 🔗 Commit SHA: 9db901b | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
This one is legacy. I'd avoid updating it in any way
There was a problem hiding this comment.
Reverted in 9db901b3. Kept the change scoped to correlate-image.ts only.
Side note: dd-source#445158 still applies the same ci.job.id fix on the GitOps correlate endpoint backend. If correlate is fully deprecated and we expect no more customer traffic on it, we can close #445158 and roll it back. Otherwise the backend fix is harmless and helps any legacy customers still on the GitOps flow. Up to you.
|
/merge |
|
View all feedbacks in Devflow UI.
This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
devflow unqueued this merge request: It did not become mergeable within the expected time |
What this changes
Two related fixes to the
deployment correlateanddeployment correlate-imagecommands:correlate-imagenow sends aci_envattribute on its request payload, mirroring the siblingcorrelate(GitOps) command. The backend uses it to derivepipeline_correlation_idandjob_correlation_id.getGithubJobIDFromLogs) before building the CI span tags, soci.job.idcarries the numeric ID instead of the workflow job name.Why
The backend (
/api/v2/ci/deployments/correlate-imagein dd-source) needsci_envto derive CI correlation IDs. Same wire shape ascorrelateso we are not inventing a new format.For GitHub Actions, the numeric check run ID is not in any standard env var. It only lives in the runner diagnostic log files. The CI visibility commands (
junit upload,trace) already use this approach. Without it,ci.job.idends up being the workflow job name (for example"build"), the backend cannot parse that as an int64, andjob_correlation_idstays empty on every GitHub deployment.Example payload
{ "data": { "type": "ci_deployment_correlate_image", "attributes": { "commit_sha": "abcdef", "repository_url": "https://github.com/DataDog/example", "image": "my-image:latest", "ci_env": { "ci.job.id": "29891234567", "ci.pipeline.id": "12345", "ci.provider.name": "github", "GITHUB_SERVER_URL": "https://github.com", "GITHUB_REPOSITORY": "DataDog/example", "GITHUB_RUN_ID": "12345", "GITHUB_RUN_ATTEMPT": "1" } } } }Companion backend PRs
correlate-image+ci.job.idfix)ci.job.idfix on the existingcorrelateendpoint)Safe to ship before the backends land. Older endpoint versions ignore unknown attributes.
Test plan
yarn test packages/plugin-deployment/src/__tests__/correlate-image.test.tspasses, including new coverage forci_envpopulation.yarn lintclean.