project_loader: add build-environment part property
Metadata
Current evaluation
Merged into master. Adds a build-environment property to snapcraft parts for declarative environment variable definition. Resolves LP: #1778174. Approved and passed CI.
Suggested action: —
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 |
|---|---|---|---|---|
| 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. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged by maintainer kyrofa, adding a build-environment property to snapcraft.yaml parts for declarative environment variable definition. Resolves Launchpad bug #1778174. Codecov confirmed 100% diff coverage. |
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 fix to load the build-environment after the snapcraft environment, enabling access to internal variables like $SNAPCRAFT_PART_INSTALL. The change swaps the evaluation order in the project loader and was approved by maintainers. | |
| #3122 pluginhandler: make the build environment available to all steps | snapcraft | merged | Merged. Reviewer feedback refined scoping: build environment is now available across all plugin steps. SNAPCRAFT_STAGE stays global, build-environment stays on the build step. Changes affect 10 files. |