project_loader: add build-environment part property
Metadata
Current evaluation
Merged in snapcraft#2322 (commit d17b67d20), adding an ordered part-level build-environment property for lifecycle variables and resolving LP #1778174.
Resolution: closed resolved
Reason: PR #2322 was merged as commit d17b67d20. Its merged change introduced declarative build-environment support for part lifecycles.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [x] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [x] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [x] If this is a bugfix. Have you checked that there is a bug report open for the issue you are trying to fix on [bug reports](https://bugs.launchpad.net/snapcraft)?
- [x] If this is a new feature. Have you discussed the design on the [forum](https://forum.snapcraft.io)?
- [x] Have you successfully run `./runtests.sh static`?
- [ ] Have you successfully run `./runtests.sh tests/unit`?
-----
Beyond using a custom plugin, there is no way for a part to specify environment variables to be defined during the part's lifecycle. This PR resolves [LP: #1778174](https://bugs.launchpad.net/snapcraft/+bug/1778174) by adding a new property to support doing so declaratively in the snapcraft.yaml, called `build-environment`. Its usage looks like this:
parts:
my-part:
plugin: <plugin name>
build-environment:
- VARIABLE1_NAME: VARIABLE1_VALUE
- VARIABLE2_NAME: VARIABLE2_VALUE
Note that, as a list, these are exported in order, which allows for later values to override (or modify) earlier values. Similarly, the `build-environment` from dependencies will be defined before that of the dependent's, allowing for it to be modified/overwritten by the dependent.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged in snapcraft#2322 (commit d17b67d20), adding an ordered part-level build-environment property for lifecycle variables and resolving LP #1778174. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged via #2322 (commit d17b67d20), adding a part-level build-environment property for ordered environment-variable declarations; resolves LP #1778174. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged into master. Adds a build-environment property to snapcraft parts for declarative environment variable definition. Resolves LP: #1778174. Approved and passed CI. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged by maintainer kyrofa, this change adds a build-environment property to snapcraft.yaml parts for declarative environment variable definition during builds. It resolves Launchpad bug #1778174 and passed code coverage checks. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #2744 project_loader: load build-environment after snapcraft environment | snapcraft | merged | Merged PR #2744 (commit f3799a5dc) reordered project-loader evaluation so build-environment loads after Snapcraft's environment, enabling variables such as $SNAPCRAFT_PART_INSTALL. | |
| #2472 project loader: do not leak a part's build-environment | snapcraft | merged | Merged #2472 as commit 8ca7dd7f2, preventing a part's build environment from leaking into parts declared with after and avoiding unintended concatenation. | |
| #1778174 Environment variable customization should be possible with scriptlet+snapcraftctl | snapcraft (launchpad) | closed | Added per-part build-environment support in snapcore/snapcraft PR #2322 (commit d17b67d20), enabling custom environment variables for scriptlets. |