[JIRA] (JENKINS-50029) Powershell treats warnings as errors

3 views
Skip to first unread message

wouter.slob@ortec.com (JIRA)

unread,
Mar 8, 2018, 1:59:02 PM3/8/18
to jenkinsc...@googlegroups.com
Wouter Slob created an issue
 
Jenkins / Bug JENKINS-50029
Powershell treats warnings as errors
Issue Type: Bug Bug
Assignee: Unassigned
Components: durable-task-plugin
Created: 2018-03-08 18:58
Environment: Latest Jenkins LTS, Durable-task plugin v2.21
Priority: Major Major
Reporter: Wouter Slob

After upgrading to the latest Jenkins LTS & durable task plugin (v1.21) our pipelines fail on warnings.

Pipeline:

node() {
    bat 'C:\\Python27\\python.exe -c "import warnings;warnings.warn(\'future\', FutureWarning)"'

    powershell 'C:\\Python27\\python.exe -c "import warnings;warnings.warn(\'future\', FutureWarning)"'
}

Output:
2018-03-08 19:47:13 [src] Running batch script
2018-03-08 19:47:14
2018-03-08 19:47:14 d:\src>C:\Python27\python.exe -c "import warnings;warnings.warn('future', FutureWarning)"
2018-03-08 19:47:17 -c:1: FutureWarning: future
[Pipeline] powershell
2018-03-08 19:47:18 [src] Running PowerShell script
2018-03-08 19:47:20 powershell.exe : -c:1: FutureWarning: future
2018-03-08 19:47:20 At D:\src@tmp\durable-4343e8b5\powershellWrapper.ps1:3 char:1
2018-03-08 19:47:20 + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File ...
2018-03-08 19:47:20 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-03-08 19:47:20 + CategoryInfo : NotSpecified: (-c:1: FutureWarning: future:Strin g) [], RemoteException
2018-03-08 19:47:20 + FullyQualifiedErrorId : NativeCommandError
2018-03-08 19:47:20

So somehow, somewhere, the warning is transformed / interpreted as an error.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.3.0#73011-sha1:3c73d0e)
Atlassian logo

wouter.slob@ortec.com (JIRA)

unread,
Mar 8, 2018, 2:00:02 PM3/8/18
to jenkinsc...@googlegroups.com
Wouter Slob assigned an issue to Sam Van Oort
Change By: Wouter Slob
Assignee: Sam Van Oort

wouter.slob@ortec.com (JIRA)

unread,
Mar 8, 2018, 2:01:02 PM3/8/18
to jenkinsc...@googlegroups.com
Wouter Slob updated an issue
After upgrading to the latest Jenkins LTS & durable task plugin (v1.21) our pipelines fail on warnings.

Pipeline:
{code:java}

node() {
    bat 'C:\\Python27\\python.exe -c "import warnings;warnings.warn(\'future\', FutureWarning)"'

    powershell 'C:\\Python27\\python.exe -c "import warnings;warnings.warn(\'future\', FutureWarning)"'
}
{code}
{quote}Output:

2018-03-08 19:47:13 [src] Running batch script
2018-03-08 19:47:14
2018-03-08 19:47:14 d:\src>C:\Python27\python.exe -c "import warnings;warnings.warn('future', FutureWarning)"
2018-03-08 19:47:17 -c:1: FutureWarning: future
[Pipeline] powershell
{color:#ff0000}2018-03-08 19:47:18 [src] Running PowerShell script{color}
{color:#ff0000} 2018-03-08 19:47:20 powershell.exe : -c:1: FutureWarning: future{color}
{color:#ff0000} 2018-03-08 19:47:20 At D:\src@tmp\durable-4343e8b5\powershellWrapper.ps1:3 char:1{color}
{color:#ff0000} 2018-03-08 19:47:20 + & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -File ...{color}
{color:#ff0000} 2018-03-08 19:47:20 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{color}
{color:#ff0000} 2018-03-08 19:47:20 + CategoryInfo : NotSpecified: (-c:1: FutureWarning: future:Strin g) [], RemoteException{color}
{color:#ff0000} 2018-03-08 19:47:20 + FullyQualifiedErrorId : NativeCommandError{color}
{color:#ff0000} 2018-03-08 19:47:20{color}
{quote}
This returns in "1" exit code, causing the pipeline to fail.

So somehow, somewhere, the warning is transformed / interpreted as an error.

svanoort@cloudbees.com (JIRA)

unread,
Mar 8, 2018, 2:17:02 PM3/8/18
to jenkinsc...@googlegroups.com
Sam Van Oort assigned an issue to Unassigned
Change By: Sam Van Oort
Assignee: Sam Van Oort

svanoort@cloudbees.com (JIRA)

unread,
Mar 8, 2018, 2:18:02 PM3/8/18
to jenkinsc...@googlegroups.com
Sam Van Oort commented on Bug JENKINS-50029
 
Re: Powershell treats warnings as errors

Gabriel Loewen Would you be able to take a look? You're the guru on the Powershell end of things here.

gabloe@microsoft.com (JIRA)

unread,
Mar 8, 2018, 2:35:03 PM3/8/18
to jenkinsc...@googlegroups.com

Actually, from the context of PowerShell it is an error.  You are executing a native command and that command is producing what PowerShell is interpreting as an error, which is written to the error stream and then caught by the PowerShell pipeline step.  You can test this out for yourself in a PowerShell session by executing that command and then checking the error history in $Error, which is a PowerShell automatic variable containing an array of errors. 

Normally this would be a non-fatal error, but because of an issue with how errors are handled in the PowerShell pipeline step it is treated as a fatal error and exiting.

Sam Van Oort I have submitted a PR that fixes this issue, [67|https://github.com/jenkinsci/durable-task-plugin/pull/67], so it should be fixed as soon as that PR is merged and a new version is cut 

gabloe@microsoft.com (JIRA)

unread,
Mar 8, 2018, 2:36:03 PM3/8/18
to jenkinsc...@googlegroups.com
Gabriel Loewen edited a comment on Bug JENKINS-50029
Actually, from the context of PowerShell it is an error.  You are executing a native command and that command is producing what PowerShell is interpreting as an error, which is written to the error stream and then caught by the PowerShell pipeline step.  You can test this out for yourself in a PowerShell session by executing that command and then checking the error history in $Error, which is a PowerShell automatic variable containing an array of errors. 

Normally this would be a non-fatal error, but because of an issue with how errors are handled in the PowerShell pipeline step it is treated as a fatal error and exiting.

[~svanoort] I have submitted a PR that fixes this issue, [67| {color:#333333} [ https://github.com/jenkinsci/durable-task-plugin/pull/67 ] {color} ] , so it should be fixed as soon as that PR is merged and a new version is cut :)

gabloe@microsoft.com (JIRA)

unread,
Mar 8, 2018, 2:38:03 PM3/8/18
to jenkinsc...@googlegroups.com
Gabriel Loewen assigned an issue to Gabriel Loewen
 
Change By: Gabriel Loewen
Assignee: Gabriel Loewen

svanoort@cloudbees.com (JIRA)

unread,
Mar 8, 2018, 3:41:02 PM3/8/18
to jenkinsc...@googlegroups.com
Sam Van Oort commented on Bug JENKINS-50029
 
Re: Powershell treats warnings as errors

Gabriel Loewen That's fine, I'll try to get someone who knows windows to do a review tomorrow and then once review is sold we can release. Do you have anything else pending though? I'd like to aim for one more rollup-release of Durable Task and then focus on longer-ranged enhancements for a bit.

gabloe@microsoft.com (JIRA)

unread,
Mar 8, 2018, 3:43:01 PM3/8/18
to jenkinsc...@googlegroups.com

No, nothing else pending from me. Just trying to fix the bugs as quickly as I find them 

wouter.slob@ortec.com (JIRA)

unread,
Mar 8, 2018, 4:51:01 PM3/8/18
to jenkinsc...@googlegroups.com

Thnx Sam Van Oort & Gabriel Loewen for prompt response and explanation. I'm looking forward to testing the upcoming patch.

 

I'm not sure if it is related to the same plugin, but yesterday I've created another issue: JENKINS-49986. You might want to have a quick look at that one

 

svanoort@cloudbees.com (JIRA)

unread,
Mar 13, 2018, 2:32:02 PM3/13/18
to jenkinsc...@googlegroups.com
Sam Van Oort closed an issue as Done
 

Released with version 1.22

Change By: Sam Van Oort
Status: Open Closed
Resolution: Done

jakub.michalec@medius-group.pl (JIRA)

unread,
Apr 9, 2018, 3:16:03 AM4/9/18
to jenkinsc...@googlegroups.com
Jakub Michalec commented on Bug JENKINS-50029
 
Re: Powershell treats warnings as errors

Gabriel Loewen related to https://jenkins.io/blog/2017/07/26/powershell-pipeline/ - Failed step caused by a non-empty error stream, in our jobs we use:

def status = powershell returnStatus: true, script: """ . .\\scripts\\someScript.ps1" """

if(status != 0) { powershell ("Write-Error \"Ooops, an error occured\"") }

If anything goes wrong it should fail job and run post action, after that fix (upgrade to 1.22) job goes further.

 

Adding explicit exit 1, should fix it from our perspective, but from my perspective write-error should stop execution

gabloe@microsoft.com (JIRA)

unread,
Apr 9, 2018, 9:33:01 AM4/9/18
to jenkinsc...@googlegroups.com

Write-Error does not typically fail a PowerShell script unless you set ErrorActionPreference to "Stop" or explicitly pass -ErrorAction to the cmdlet.

gabloe@microsoft.com (JIRA)

unread,
Apr 9, 2018, 9:37:02 AM4/9/18
to jenkinsc...@googlegroups.com

E.g. the error stream is technically ignored if your error action proference is not set to "Stop"

gabloe@microsoft.com (JIRA)

unread,
Apr 9, 2018, 9:42:02 AM4/9/18
to jenkinsc...@googlegroups.com

sebastianslutzky@gmail.com (JIRA)

unread,
Oct 21, 2019, 10:57:03 AM10/21/19
to jenkinsc...@googlegroups.com
sebastian slutzky assigned an issue to sebastian slutzky
 
Change By: sebastian slutzky
Assignee: Gabriel Loewen sebastian slutzky
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

sebastianslutzky@gmail.com (JIRA)

unread,
Oct 21, 2019, 10:58:03 AM10/21/19
to jenkinsc...@googlegroups.com
sebastian slutzky assigned an issue to Gabriel Loewen
Change By: sebastian slutzky
Assignee: sebastian slutzky Gabriel Loewen
Reply all
Reply to author
Forward
0 new messages