Skip to content

Bug: make.ps1 leaks global environment variables and state on build failures #2413

Description

@Piyush0049

Jenkins and plugins versions report

N/A - This applies to the repository's local PowerShell build scripts, not a Jenkins instance.

What Operating System are you using (both controller, and any agents involved in the problem)?

Windows (Local build/development environment)

Reproduction steps

  1. Dot-source make.ps1 or run Test-Image locally.
  2. Simulate a failure during the docker buildx step in Initialize-DockerComposeFile, or a failure during Invoke-Pester in Test-Image.
  3. Check the PowerShell environment variables ($env:WINDOWS_VERSION_OVERRIDE, $env:CONTROLLER_TAG, $env:LATEST_LTS).

Expected Results

The script should safely restore or clean up temporary environment variables before exiting, so the developer's terminal remains pristine for the next build.

Actual Results

The variables are left permanently orphaned in the developer's terminal session because the script crashes before reaching the Remove-Item env:* lines. This silently hijacks subsequent local builds (e.g. building the wrong Windows version override). Additionally, building a Weekly release and then an LTS release bleeds state because the inverse release variable is never unset.

Anything else?

No response

Are you interested in contributing a fix?

Yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions