Skip to content

[cli] Add --id flag to build and env pull for deployment-scoped env vars#15805

Merged
ofhouse merged 6 commits intomainfrom
ofhouse/build-env-pull-deployment-id
Apr 3, 2026
Merged

[cli] Add --id flag to build and env pull for deployment-scoped env vars#15805
ofhouse merged 6 commits intomainfrom
ofhouse/build-env-pull-deployment-id

Conversation

@ofhouse
Copy link
Copy Markdown
Member

@ofhouse ofhouse commented Apr 1, 2026

Context

For the BYOC workflow, vercel build needs access to the same environment variables that the build-container receives. Currently it loads env vars from local .env files created by vercel pull, which miss deployment-specific vars (integration overrides, system vars like VERCEL_URL/VERCEL_DEPLOYMENT_ID, LaunchDarkly flags, etc.).

This adds --id support to both vercel build and vercel env pull so they can fetch the fully resolved env vars stored on a specific deployment.

Changes

  • Added --id flag to vercel build — when provided, fetches buildEnv from the deployment via the env pull API instead of loading from local .env files. Polls if integrations are still provisioning (checks integrationsStatus in the error response, 5s interval, 3min timeout matching the API).
  • Added --id flag to vercel env pull — when provided, fetches env from the deployment in one shot (no polling). Writes to file same as before.
  • Updated pullEnvRecords() to accept deployment IDs — skips target/gitBranch path segments when the ID starts with dpl_.
  • Added telemetry tracking for the new --id option in both commands.

References

  • Depends on vercel/api#66324 (API-side: extends pull-env-vars endpoint to accept deployment IDs)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

🦋 Changeset detected

Latest commit: 3c38cfb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
vercel Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

📦 CLI Tarball Ready

The Vercel CLI tarball for this PR is now available!

Quick Test

You can test this PR's CLI directly by running:

npx https://vercel-b2n2zalyx.vercel.sh/tarballs/vercel.tgz --help

Use in vercel.json

To use this CLI version in your project builds, add to your vercel.json:

{
  "build": {
    "env": {
      "VERCEL_CLI_VERSION": "vercel@https://vercel-b2n2zalyx.vercel.sh/tarballs/vercel.tgz"
    }
  }
}

Python Runtime Wheel

A vercel-runtime wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_RUNTIME_PYTHON="vercel-runtime @ https://vercel-b2n2zalyx.vercel.sh/tarballs/vercel_runtime-0.13.0.dev1775228301+29fb7ce-py3-none-any.whl"

Python Workers Wheel

A vercel-workers wheel was also built for this PR.
To use in your Python project builds, also set this environment variable:

VERCEL_WORKERS_PYTHON="vercel-workers @ https://vercel-b2n2zalyx.vercel.sh/tarballs/vercel_workers-0.1.0.dev1775228301+29fb7ce-py3-none-any.whl"

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

🧪 Unit Test Strategy

Comparing: d034d903c38cfb (view diff)

Strategy: Code changed outside of a package - running all unit tests

⚠️ All unit tests will run because global code changes could impact all packages.

Affected packages - 15 (38%)
  1. vercel
  2. @vercel/build-utils
  3. @vercel/client
  4. @vercel/firewall
  5. @vercel/fs-detectors
  6. @vercel/go
  7. @vercel/hydrogen
  8. @vercel/next
  9. @vercel/node
  10. @vercel/python
  11. @vercel/remix-builder
  12. @vercel/ruby
  13. @vercel/rust
  14. @vercel/static-build
  15. examples
Unaffected packages - 25 (63%)
  1. @vercel-internals/get-package-json
  2. @vercel/backends
  3. @vercel/cervel
  4. @vercel/cli-auth
  5. @vercel/config
  6. @vercel/detect-agent
  7. @vercel/edge
  8. @vercel/elysia
  9. @vercel/error-utils
  10. @vercel/express
  11. @vercel/fastify
  12. @vercel/frameworks
  13. @vercel/functions
  14. @vercel/gatsby-plugin-vercel-builder
  15. @vercel/h3
  16. @vercel/hono
  17. @vercel/koa
  18. @vercel/nestjs
  19. @vercel/oidc
  20. @vercel/oidc-aws-credentials-provider
  21. @vercel/python-analysis
  22. @vercel/redwood
  23. @vercel/related-projects
  24. @vercel/routing-utils
  25. @vercel/static-config

Results

  • Unit tests: All affected packages will run unit tests
  • E2E tests: Running in parallel via E2E Tests workflow
  • Type checks: All affected packages will run type checks

This comment is automatically generated based on the affected testing strategy

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 1, 2026

Low Risk — CLI feature addition — new optional --id flag for fetching deployment-scoped env vars.

  • command.ts: added --id flag definition to build and env pull commands
  • build/index.ts: fetch env vars from deployment API when --id provided, with polling for integrations
  • get-env-records.ts: skip target/gitBranch path segments when ID starts with dpl_

Assessed at 3c38cfb.

@ofhouse ofhouse marked this pull request as ready for review April 3, 2026 15:54
@ofhouse ofhouse requested review from a team as code owners April 3, 2026 15:54
@ofhouse ofhouse merged commit 16f663a into main Apr 3, 2026
243 of 245 checks passed
@ofhouse ofhouse deleted the ofhouse/build-env-pull-deployment-id branch April 3, 2026 16:23
ofhouse pushed a commit that referenced this pull request Apr 3, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## [email protected]

### Minor Changes

- Add `vercel tokens` subcommands (`ls`, `add`, `rm`) for auth token API
parity with the dashboard.
([#15812](#15812))

- Add `vercel project access-summary` subcommand to list member counts
by role for a project.
([#15813](#15813))

- Add `vercel project members` and `vercel project access-groups`
commands, and fix `vercel teams members` to fetch all pages from the
paginated team members API.
([#15786](#15786))

### Patch Changes

- Add `--id` flag to `vercel build` and `vercel env pull` to fetch
deployment-scoped environment variables
([#15805](#15805))

-   Updated dependencies \[]:
    -   @vercel/[email protected]

## @vercel/[email protected]

### Minor Changes

- Add Mastra framework preset
([#15076](#15076))

## @vercel/[email protected]

### Patch Changes

- Updated dependencies
\[[`d034d90dcf78316ddacdcce8fd51329fb7eefe82`](d034d90)]:
    -   @vercel/[email protected]

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants