Add env section to bundle scripts for DABs interpolation - #5299
Merged
Conversation
shreyas-goenka
temporarily deployed
to
test-trigger-is
May 21, 2026 13:44 — with
GitHub Actions
Inactive
shreyas-goenka
temporarily deployed
to
test-trigger-is
May 21, 2026 13:44 — with
GitHub Actions
Inactive
shreyas-goenka
force-pushed
the
script-env-section
branch
from
June 16, 2026 14:49
932c672 to
0452148
Compare
shreyas-goenka
temporarily deployed
to
test-trigger-is
June 16, 2026 14:50 — with
GitHub Actions
Inactive
shreyas-goenka
temporarily deployed
to
test-trigger-is
June 16, 2026 14:50 — with
GitHub Actions
Inactive
Collaborator
Integration test reportCommit: a32d68c
9 interesting tests: 4 RECOVERED, 4 SKIP, 1 flaky
Top 10 slowest tests (at least 2 minutes):
|
shreyas-goenka
force-pushed
the
script-env-section
branch
5 times, most recently
from
June 29, 2026 16:37
f373d61 to
b68897d
Compare
scripts.<name> now accepts an env: map whose values may reference
${bundle.*}, ${workspace.*}, and ${var.*}. The script content is still
passed to the shell as-is (no DABs interpolation), removing the ambiguity
between bundle variables and shell variables that previously forced all
${...} usage to be rejected.
When an env value references an unsupported prefix (e.g. ${resources.*}),
validation reports a clear error pointing at the field. The content-side
error now suggests the new env section instead of just stating ${...} is
unsupported.
Fixes #4179
Co-authored-by: Isaac
shreyas-goenka
force-pushed
the
script-env-section
branch
from
June 30, 2026 08:13
b68897d to
8044e34
Compare
shreyas-goenka
marked this pull request as ready for review
July 6, 2026 13:30
Resolved conflicts in NEXT_CHANGELOG.md (kept both entry sets) and bundle/internal/schema/annotations.yml (took main's regenerated layout, re-added the scripts env field annotation). Co-authored-by: Isaac
shreyas-goenka
temporarily deployed
to
test-trigger-is
July 6, 2026 13:37 — with
GitHub Actions
Inactive
shreyas-goenka
had a problem deploying
to
test-trigger-is
July 6, 2026 13:37 — with
GitHub Actions
Failure
denik
reviewed
Jul 6, 2026
denik
reviewed
Jul 6, 2026
Fix the earlier bad merge in NEXT_CHANGELOG.md: the prior merge resurrected Bundles entries that had already been swept into the v1.6.0 release. Reset the changelog to origin/main and re-added only the scripts env entry. Co-authored-by: Isaac
shreyas-goenka
temporarily deployed
to
test-trigger-is
July 6, 2026 22:33 — with
GitHub Actions
Inactive
shreyas-goenka
temporarily deployed
to
test-trigger-is
July 6, 2026 22:33 — with
GitHub Actions
Inactive
| PLACEHOLDER | ||
| "env": | ||
| "description": |- | ||
| PLACEHOLDER |
Contributor
There was a problem hiding this comment.
please add a description here so it shows up in tooltips via the jsonschema
Contributor
Author
There was a problem hiding this comment.
Done — added a description for scripts.<name>.env in annotations.yml (regenerated jsonschema.json).
Comment on lines
+281
to
+286
| env := scriptEnv(cmd, b) | ||
| // Append after the auth/target variables so a script's env: section takes | ||
| // precedence on collision (os/exec uses the last value for a duplicate key). | ||
| for _, name := range slices.Sorted(maps.Keys(script.Env)) { | ||
| env = append(env, name+"="+script.Env[name]) | ||
| } |
Contributor
There was a problem hiding this comment.
add an acceptance test for this
Contributor
Author
There was a problem hiding this comment.
Added the env-precedence acceptance test: a script's env: entry sets DATABRICKS_BUNDLE_TARGET=from-script-env and the output confirms it wins over the CLI-injected value.
| @@ -0,0 +1 @@ | |||
| errcode trace $CLI bundle validate | |||
Contributor
There was a problem hiding this comment.
Suggested change
| errcode trace $CLI bundle validate | |
| musterr trace $CLI bundle validate |
Contributor
Author
There was a problem hiding this comment.
Applied musterr (dropped the redundant errcode).
- Add a real description for scripts.<name>.env in annotations.yml so it surfaces in jsonschema tooltips (regenerated jsonschema.json). - Use musterr instead of errcode in the env-bad-prefix script to assert the command must fail. - Add an env-precedence acceptance test proving a script's env: entry overrides a CLI-injected variable (DATABRICKS_BUNDLE_TARGET). Co-authored-by: Isaac
v1.8.0 was cut, emptying the Bundles section of NEXT_CHANGELOG.md on main. Kept only the scripts env entry. Co-authored-by: Isaac
janniklasrose
approved these changes
Jul 10, 2026
shreyas-goenka
temporarily deployed
to
test-trigger-is
July 10, 2026 09:52 — with
GitHub Actions
Inactive
shreyas-goenka
temporarily deployed
to
test-trigger-is
July 10, 2026 09:52 — with
GitHub Actions
Inactive
Collaborator
Integration test reportCommit: a152b60
33 interesting tests: 17 FAIL, 9 flaky, 4 RECOVERED, 2 SKIP, 1 KNOWN
Top 50 slowest tests (at least 2 minutes):
|
shreyas-goenka
added a commit
that referenced
this pull request
Jul 14, 2026
ronaldz-db
pushed a commit
to ronaldz-db/cli
that referenced
this pull request
Jul 15, 2026
…sue databricks#4179 (databricks#5923) The fragment added by databricks#5831 linked the `env:` section changelog entry to the original issue (databricks#4179) rather than the PR that implemented the feature (databricks#5299). This includes both links.
deco-sdk-tagging Bot
added a commit
that referenced
this pull request
Jul 15, 2026
## Release v1.8.0 ### Notable Changes * Auto-migrate a bundle from terraform to the direct engine when `bundle.engine` is `"direct"` (or `DATABRICKS_BUNDLE_ENGINE=direct`) and the post-deploy dry-run migration is clean; a warning is emitted if the dry-run surfaces errors or warnings so the automatic migration is skipped. ### CLI * experimental `ssh connect`: bare `python`/`pip` in an interactive session now resolve to the environment interpreter (`$DATABRICKS_VIRTUAL_ENV`) instead of the system or cluster-libraries interpreter, so packages installed in the environment are importable without extra setup. The interactive shell is now non-login (`bash -i`) and the server seeds a `~/.bashrc` snippet that re-prepends the environment's bin directory to `PATH` ([#5888](#5888)). * When Claude Code runs the CLI without the Databricks AI tooling installed, the CLI now prints a one-line recommendation on stderr to run `databricks aitools install`. The recommendation is shown at most once per hour per Claude session, and never for human callers or `aitools` commands. * Fixed `databricks auth describe` misattributing a profile selected via `DATABRICKS_CONFIG_PROFILE` as `(from bundle)` when run inside a bundle root ([#5904](#5904)). ### Bundles * `bundle generate` now warns when the generated configuration file is not matched by any pattern in the `include` section of `databricks.yml` ([#5868](#5868)). * direct: Match UC Auto Upgrade managed property defaults with a wildcard pattern instead of enumerating each key ([#5877](#5877)). * Recognize `ssh://` template URLs in `databricks bundle init` ([#5891](#5891)). * `databricks bundle init` now reports an actionable error when given a template URL with an unsupported protocol (`http://`, `git://`, `ftp://`, `ftps://`) instead of failing with a confusing "not a bundle template" message ([#5902](#5902)). * Added an `env:` section to `scripts.<name>` for declaring environment variables that may reference `${bundle.*}`, `${workspace.*}`, and `${var.*}` ([#4179](#4179), [#5299](#5299)).
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.
Fixes #4179.
Adds an
env:map toscripts.<name>. Values may reference${bundle.*},${workspace.*}, and${var.*}; they're resolved before the script runs and exported into its shell, wherecontentuses plain$NAME:contentis still passed to the shell as-is, so${...}incontentstays unsupported (the error now points to theenv:section). Env values with any other prefix (e.g.${resources.*}) are rejected. On a name collision with the CLI-injected auth vars, the script'senv:wins.This pull request was AI-assisted by Isaac.