Skip to content

deployment correlate-image: include ci_env in request payload#2328

Open
DaniFdz wants to merge 3 commits into
masterfrom
dani.fernandez/correlate-image-ci-env
Open

deployment correlate-image: include ci_env in request payload#2328
DaniFdz wants to merge 3 commits into
masterfrom
dani.fernandez/correlate-image-ci-env

Conversation

@DaniFdz
Copy link
Copy Markdown

@DaniFdz DaniFdz commented May 20, 2026

What this changes

Two related fixes to the deployment correlate and deployment correlate-image commands:

  1. correlate-image now sends a ci_env attribute on its request payload, mirroring the sibling correlate (GitOps) command. The backend uses it to derive pipeline_correlation_id and job_correlation_id.
  2. Both commands now read the GitHub Actions numeric check run ID from the runner diagnostic log files (via getGithubJobIDFromLogs) before building the CI span tags, so ci.job.id carries the numeric ID instead of the workflow job name.

Why

The backend (/api/v2/ci/deployments/correlate-image in dd-source) needs ci_env to derive CI correlation IDs. Same wire shape as correlate so 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.id ends up being the workflow job name (for example "build"), the backend cannot parse that as an int64, and job_correlation_id stays 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

  • DataDog/dd-source#443772 (writer for correlate-image + ci.job.id fix)
  • DataDog/dd-source#445158 (same ci.job.id fix on the existing correlate endpoint)
  • DataDog/dd-go#238027 (reader on the ArgoCD path)

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.ts passes, including new coverage for ci_env population.
  • yarn lint clean.
  • Validated end-to-end in staging.

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.
@datadog-datadog-prod-us1
Copy link
Copy Markdown

datadog-datadog-prod-us1 Bot commented May 20, 2026

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 9db901b | Docs | Datadog PR Page | Give us feedback!

@DaniFdz DaniFdz added the software-delivery Related to [coverage, deployment, dora, junit, measure, tag, trace] label May 21, 2026
@DaniFdz DaniFdz marked this pull request as ready for review May 22, 2026 09:20
@DaniFdz DaniFdz requested review from a team as code owners May 22, 2026 09:20
@DaniFdz DaniFdz requested a review from PabloRzBo May 22, 2026 09:20
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is legacy. I'd avoid updating it in any way

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@DaniFdz
Copy link
Copy Markdown
Author

DaniFdz commented May 22, 2026

/merge

@gh-worker-devflow-routing-ef8351
Copy link
Copy Markdown

gh-worker-devflow-routing-ef8351 Bot commented May 22, 2026

View all feedbacks in Devflow UI.

2026-05-22 11:03:07 UTC ℹ️ Start processing command /merge


2026-05-22 11:03:13 UTC ℹ️ MergeQueue: waiting for PR to be ready

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.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-05-22 15:52:18 UTC ⚠️ MergeQueue: This merge request was unqueued

devflow unqueued this merge request: It did not become mergeable within the expected time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mergequeue-status: removed software-delivery Related to [coverage, deployment, dora, junit, measure, tag, trace]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants