-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for Batch scripts not properly signalling a failure in a pipeline #4784
Fix for Batch scripts not properly signalling a failure in a pipeline #4784
Conversation
… when using 'exit /b 1'. Instead generate a real failure that will cause the pipeline to behave correctly. Signed-off-by: Jason Archer <jasonmarcher@gmail.com>
Repaired failing test. It really needs to be written better. I may do that. |
Not sure why the diff is showing the whole test class changing, I probably got the line endings changed. Will investigate later. The real change is a single line in the line ending test. |
…Linux line endings present. Signed-off-by: Jason Archer <jasonmarcher@gmail.com>
5aec1d0
to
819f46d
Compare
Thanks for your contribution. I'm sorry we didn't get back to you in a reasonable amount of time. If someone thinks this change is still valuable, please submit a new PR. Thanks again! |
Windows script `gradlew.bat` executes Gradle within its own, batch context. This causes every locally declared variable to be visible to underlying `java` process, *potentially* leaking information about used options and classpath. To mitigate this, we jump to a non-existent label, forcing `cmd.exe` to stop processing the script, yet run the remaining commands within the current line in parent (most likely command-line when invoking `gradlew` directly) context. This introduces a harmless side-effect in form of corrupting the current title of the window `cmd.exe` was invoked in, thus it is reset to the default value. This provides a few side benefits: - no more 'Terminate batch job (Y/N)?' prompt - `call ` and `call` are used to directly set exit code, resolving gradle#4784 - both sh and `cmd.exe` scripts become synchronized in terms of mechanism used to execute JVM as well as environment sanitization Issue: gradle#10463 Signed-off-by: mataha <mataha@users.noreply.github.com>
Windows script `gradlew.bat` executes Gradle within its own, batch context. This causes every locally declared variable to be visible to underlying `java` process, *potentially* leaking information about used options and classpath. To mitigate this, we jump to a non-existent label, forcing `cmd.exe` to stop processing the script, yet run the remaining commands within the current line in parent (most likely command-line when invoking `gradlew` directly) context. This introduces a harmless side-effect in form of corrupting the current title of the window `cmd.exe` was invoked in, thus it is reset to the default value. This provides a few side benefits: - no more 'Terminate batch job (Y/N)?' prompt - `call ` and `call` are used to directly set exit code, resolving gradle#4784 - both sh and `cmd.exe` scripts become synchronized in terms of mechanism used to execute JVM as well as environment sanitization Issue: gradle#10463 Signed-off-by: mataha <mataha@users.noreply.github.com>
Windows script `gradlew.bat` executes Gradle within its own, batch context. This causes every locally declared variable to be visible to underlying `java` process, *potentially* leaking information about used options and classpath. To mitigate this, we jump to a non-existent label, forcing `cmd.exe` to stop processing the script, yet run the remaining commands within the current line in parent (most likely command-line when invoking `gradlew` directly) context. This introduces a harmless side-effect in form of corrupting the current title of the window `cmd.exe` was invoked in, thus it is reset to the default value. This provides a few side benefits: - no more 'Terminate batch job (Y/N)?' prompt - `call ` and `call` are used to directly set exit code, resolving gradle#4784 - both sh and `cmd.exe` scripts become synchronized in terms of mechanism used to execute JVM as well as environment sanitization Issue: gradle#10463 Signed-off-by: mataha <mataha@users.noreply.github.com>
The Windows shell pipeline will not detect a failure when using 'exit /b 1'. Instead generate a real failure that will cause the pipeline to behave correctly.
Signed-off-by: Jason Archer jasonmarcher@gmail.com
Context
One of our developers noticed that
gradlew someTaskThatDoesNotExist && echo Success
does not behave correctly on Windows. The echo will happen even though the Gradle invocation failed.Here is a StackOverflow thread about the issue and the source of the solution used here. https://stackoverflow.com/questions/4632891/exiting-batch-with-exit-b-x-where-x-1-acts-as-if-command-completed-successfu
Contributor Checklist
<subproject>/src/integTest
) to verify changes from a user perspective<subproject>/src/test
) to verify logic./gradlew <changed-subproject>:check
Gradle Core Team Checklist