Skip to content
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

Errors are not detected as errors and out is in the wrong order #9

Open
pecigonzalo opened this issue Nov 6, 2015 · 8 comments
Open

Comments

@pecigonzalo
Copy link

I have some scripts that have errors in the execution but the job finishes as successful.
In some cases im also getting the error output printed before the output of echo commands that execute before it.

mv : Cannot create a file when that file already exists.
At C:\WINDOWS\TEMP\12-102-DIWEB_SelfService-dispatch-script.tmp.ps1:16 char:1
+ mv "./Temp/$ArtifactName" $env:TEMP
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (C:\Users\SI5559...ortal-0.5.0.zip:F 
   ileInfo) [Move-Item], IOException
    + FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Com 
   mands.MoveItemCommand

Exception calling "ExtractToDirectory" with "2" argument(s): "Could not find 
file 'C:\Users\SI555945\selfservice.portal-0.5.0.zip'."
At C:\WINDOWS\TEMP\12-102-DIWEB_SelfService-dispatch-script.tmp.ps1:19 char:1
+ [System.IO.Compression.ZipFile]::ExtractToDirectory($ArtifactName, 
"./$ArtifactN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : FileNotFoundException
@vvchik
Copy link
Contributor

vvchik commented Dec 29, 2015

I think it is known issue with powershell
please look at this, it may help
http://stackoverflow.com/questions/15777492/why-are-my-powershell-exit-codes-always-0

@vvchik
Copy link
Contributor

vvchik commented Dec 29, 2015

About order.
All output and errors is collected and after that printing in one step.
But errors printed first.
I need to do it because errors come in xml format and i need to cleanup it for better read
I may try to change code for live output, but errors anyway will be collected and printed after all.
And I not sure that simple change will help.

Want to be beta tester?

@pecigonzalo
Copy link
Author

@vvchik I understand the exit code, but maybe if you see something on stderror terminate with error... otherwise.
Im fine with errors being printed, but they should be printed in the order they would appear in a normal console output.
Im happy to beta test, just let me know which branch / release :D

Thanks!

@vvchik
Copy link
Contributor

vvchik commented Dec 30, 2015

if you see something on stderror terminate with error

Warnings also going via STERR...

@vvchik
Copy link
Contributor

vvchik commented Dec 30, 2015

@pecigonzalo
Copy link
Author

Will do this Monday morning thanks!

@pecigonzalo
Copy link
Author

Sorry for the delay i was having some issues with rundeck require of the winrm gem (still unresolved but have worked around it)

Output:

 WARN  WinRM::WinRMWebService : WinRM::WinRMWebService#run_powershell_script is deprecated. Use WinRM::CommandExecutor#run_cmd instead
gonzalop-lt001\testuser
#< CLIXML
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04"><S S="Error">dir : Cannot find drive. A drive with the name 'z' does not exist._x000D__x000A_</S><S S="Error">At line:1 char:57_x000D__x000A_</S><S S="Error">+ $ProgressPreference='SilentlyContinue';whoami;sleep 10; dir z:_x000D__x000A_</S><S S="Error">+                                                         ~~~~~~_x000D__x000A_</S><S S="Error">    + CategoryInfo          : ObjectNotFound: (z:String) [Get-ChildItem], DriveNotFoundException_x000D__x000A_</S><S S="Error">    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand_x000D__x000A_</S><S S="Error"> _x000D__x000A_</S></Objs>

Notes:

  • There where some updates to winrm gem so that might be why the warning at the beginning
  • The error at the end is not parsed properly and im seeing the xml
  • The error is displayed at the end correctly
  • The error is not detected as an error and job finished "successfully"

@pecigonzalo
Copy link
Author

Ok this seems to be an issue because of the way the winrm library outputs stderr/stdout when using run_cmd / run_powershell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants