chore(windows): fortify build scripts against environment leaks and silent crashes - #2412
Open
Piyush0049 wants to merge 2 commits into
Open
chore(windows): fortify build scripts against environment leaks and silent crashes#2412Piyush0049 wants to merge 2 commits into
Piyush0049 wants to merge 2 commits into
Conversation
Member
|
@Piyush0049 can you open an issue per type of problem you see so we can discuss it before opening any pull request please? It would greatly help us evaluate them before acting if needed. |
Contributor
Author
Sure, I would open issue before opening a PR from next time. I am opening the issues related to this PR. |
…ld-robustness # Conflicts: # make.ps1
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.
While working with the Windows build scripts, I noticed several areas where terminating exceptions (like a failing Docker build or a crashing Pester test) would bypass cleanup logic. This leaves temporary files on disk and leaks global environment variables into the developer session, which can silently hijack subsequent local builds.
This PR does the following:
$env:WINDOWS_VERSION_OVERRIDE,$env:DOCKERHUB_ORG_REPO, and$env:CONTROLLER_TAGintry/finallyblocks so they are guaranteed to be cleaned up or restored even if the build orInvoke-Pestercrashes.Get-SutImageCrash: SwapsResolve-PathforJoin-Pathto prevent rawItemNotFoundExceptioncrashes, allowing the script intended friendly error message to actually render.docker execinGet-JenkinsPasswordin atry/catchblock to ensure forward compatibility with PS 7.3+ native command error preferences.Build-DockerChilddeletesDockerfile-windows.tmpin afinallyblock if the build fails.Related Issues
Fixes #2413
Fixes #2414
Testing done
Invoke-Pesterblock and verified thefinallyblocks successfully cleaned up$env:DOCKERHUB_ORG_REPOand$env:CONTROLLER_TAG.Get-SutImagenow correctly outputs the friendly string error rather than crashing the script.Get-JenkinsPasswordare safely caught and return$nullas intended.Submitter checklist