I just installed the plugin today (v1.2) and my job did not fail even though the Powershell errored:
Started by user anonymous
[EnvInject] - Loading node environment variables.
Building on master in workspace C:\SPE\Jenkins\jobs\Test1\workspace
[EnvInject] - Injecting environment variables from a build step.
[EnvInject] - Injecting as environment variables the properties file path 'C:/SPE/Jenkins/DailyBuild/buildtime.properties'
[EnvInject] - Variables injected successfully.
[workspace] $ cmd /c call C:\Users\SPESER~1\AppData\Local\Temp\hudson868747164412287880.bat
C:\SPE\Jenkins\jobs\Test1\workspace>rem echo BUILDTIME=1027 > C:\SPE\Jenkins\DailyBuild\buildtime.properties
C:\SPE\Jenkins\jobs\Test1\workspace>exit 0
[workspace] $ powershell.exe "& 'C:\Users\SPESER~1\AppData\Local\Temp\hudson7972185748419603015.ps1'"
out-file : Could not find a part of the path 'C:\SPE\Jenkins\jobs\Test1\workspace%SE_R_MASTER%\buildtime.properties'.
At C:\Users\speservice\AppData\Local\Temp\hudson7972185748419603015.ps1:2 char:1
+ Write-Output "BUILDTIME=$time" > %SE_R_MASTER%\buildtime.properties
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OpenError: (
[Out-File], DirectoryNotFoundException
+ FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand
Finished: SUCCESS
I don't like being locked in to being path relative to workspace (the windows batch command doesn't do this). Yes, I have already adjusted my path, but my primary issue is having the false positive. That makes it unusable in a production environment.
Hello,
I tried your patch.
I agree with you about ExcetuionPolicy ByPass.
But for the exit code, I do not think this is a good solution. When a script is executed, it should be fully executed and not stop on the first error (as batch files). To stop a script, you must use "exit 1" and so fail the build.
I found a better solution fot the exit code (the same than "Execute Windows batch command").
I created a pull request with my changes.
Damien