[JIRA] (JENKINS-59529) Build is not failing when powershell script exits with "MissingMandatoryParameter" or "CommandNotFoundException"

19 views
Skip to first unread message

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:12:03 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss created an issue
 
Jenkins / Bug JENKINS-59529
Build is not failing when powershell script exits with "MissingMandatoryParameter" or "CommandNotFoundException"
Issue Type: Bug Bug
Assignee: Unassigned
Components: durable-task-plugin
Created: 2019-09-26 00:11
Priority: Minor Minor
Reporter: Brent Zeiss

The powershell command is:

buildVS 'Release' -nuget $true

 

[Pipeline] echo Running powershell command:
buildVS 'Release' -nuget $true [Pipeline] powershellpowershell.exe : buildVS : Cannot process command because of one or more missing mandatory parameters: config.
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git branch@tmp\durable-d4ee0605\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (buildVS : Canno...meters: config.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git
branch@tmp\durable-d4ee0605\powershellScript.ps1:3 char:5

+ buildVS 'Release' -nuget $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: ( [buildVS], ParameterBindingException

+ FullyQualifiedErrorId : MissingMandatoryParameter,buildVS

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:13:02 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss updated an issue
Change By: Brent Zeiss
The powershell command is:  

buildVS 'Release' -nuget $true

 

[Pipeline] echo    Running powershell command:
    buildVS  'Release' -nuget $true  [Pipeline] powershellpowershell.exe : buildVS : Cannot process command because of one or more missing mandatory parameters: config.
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git branch@tmp\durable-d4ee0605\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (buildVS : Canno...meters: config.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError


At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git
branch@tmp\durable-d4ee0605\powershellScript.ps1:3 char:5

+     buildVS  'Release' -nuget $true
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (:) [buildVS], ParameterBindingException

    + FullyQualifiedErrorId : MissingMandatoryParameter,buildVS

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:17:03 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss updated an issue
  A build will not fail when a powershell script encounters an error "MissingMandatoryParameter" or "CommandNotFoundException".

I would expect an error code other than 0, or, for the script to fail.

Here are some examples:
{code:java}
powershell "buildVS 'Release' -nuget $true"
{code}
 

Results in something similar to:
{noformat}
[Pipeline] echo Running powershell command:
buildVS 'Release' -nuget $true [Pipeline] powershellpowershell.exe : buildVS : Cannot process command because of one or more missing mandatory parameters: config.
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git branch@tmp\durable-d4ee0605\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (buildVS : Canno...meters: config.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git
branch@tmp\durable-d4ee0605\powershellScript.ps1:3 char:5

+ buildVS 'Release' -nuget $true
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: ( :) [buildVS], ParameterBindingException

+ FullyQualifiedErrorId : MissingMandatoryParameter,buildVS {noformat}
and
{code:java}
powershell "gobbledygook"
{code}
Results in something similar to:
{noformat}

[Pipeline] echo

    Running powershell command:
    gobbledygook
  
[Pipeline] powershell
powershell.exe : gobbledygook : The term 'gobbledygook' is not recognized as the name of a cmdlet, function, script file, or operable
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git branch@tmp\durable-25a0caf8\powershellWrapper.ps1:3 char:1

+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (gobbledygook : ...e, or operable :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git
branch@tmp\durable-25a0caf8\powershellScript.ps1:3 char:5
+     gobbledygook
+     ~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (gobbledygook:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException



[Pipeline] echo
Powershell exit status: 0{noformat}
 

 

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:20:02 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss updated an issue
 A build will not fail when a powershell script encounters an error "MissingMandatoryParameter" or "CommandNotFoundException".

I would expect an error code other than 0, or, for the script to fail.

Here are some examples:
{code:java}
powershell " buildVS 'Release' -nuget $true gobbledygook "
{code}
 

Results in something similar to:
{noformat}
[Pipeline] echo


Running powershell command:
buildVS 'Release' -nuget $true     gobbledygook
  
[Pipeline] powershellpowershell powershell
powershell
.exe : buildVS gobbledygook : Cannot process command because The term 'gobbledygook' is not recognized as the name of one a cmdlet, function, script file, or more missing mandatory parameters: config.
operable
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git branch@tmp\durable- d4ee0605 25a0caf8 \powershellWrapper.ps1:3 char:1

+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( buildVS gobbledygook : Canno ... meters e, or operable : config.: String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git
branch@tmp\durable- d4ee0605 25a0caf8 \powershellScript.ps1:3 char:5
+
buildVS 'Release' -nuget $true      gobbledygook
+ ~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument ObjectNotFound : ( gobbledygook:String) [ buildVS ], ParameterBindingException CommandNotFoundException
+ FullyQualifiedErrorId :
MissingMandatoryParameter,buildVS CommandNotFoundException




[Pipeline] echo
Powershell exit status: 0
{noformat}
and
{code:java}
powershell "
gobbledygook buildVS 'Release' -nuget $true "

{code}
Results in something similar to:
{noformat}
[Pipeline] echo


    Running powershell command:
    gobbledygook
  
buildVS 'Release' -nuget $true [Pipeline]
powershell
powershell
powershellpowershell .exe : gobbledygook buildVS : The term 'gobbledygook' is not recognized as the name Cannot process command because of a cmdlet, function, script file, one or operable
more missing mandatory parameters: config.
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git branch@tmp\durable- 25a0caf8 d4ee0605 \powershellWrapper.ps1:3 char:1

+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: ( gobbledygook buildVS : Canno ... e, or operable meters : config.: String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git
branch@tmp\durable- 25a0caf8 d4ee0605 \powershellScript.ps1:3 char:5
+
     gobbledygook buildVS 'Release' -nuget $true
+     ~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound InvalidArgument : ( gobbledygook:String) [ buildVS ], CommandNotFoundException ParameterBindingException
    + FullyQualifiedErrorId :
CommandNotFoundException



[Pipeline] echo
Powershell exit status: 0
MissingMandatoryParameter,buildVS {noformat}
 


 

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:24:03 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss updated an issue
 A build will not fail when a powershell script encounters an error "MissingMandatoryParameter" or "CommandNotFoundException".

I would expect an error code other than 0, or, for the script to fail.

Here are some examples:
{code:java}
powershell "gobbledygook"

{code}
Results in something similar to:
{noformat}
[Pipeline] echo

    Running powershell command:
    gobbledygook
  
[Pipeline] powershell
powershell.exe : gobbledygook : The term 'gobbledygook' is not recognized as the name of a cmdlet, function, script file, or operable
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git branch@tmp\durable-25a0caf8\powershellWrapper.ps1:3 char:1

+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (gobbledygook : ...e, or operable :String) [], RemoteException

    + FullyQualifiedErrorId : NativeCommandError

program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git
branch@tmp\durable-25a0caf8\powershellScript.ps1:3 char:5
+     gobbledygook

+     ~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (gobbledygook:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException



[Pipeline] echo
Powershell exit status: 0{noformat}
and
{code:java}
powershell "buildVS 'Release' -nuget $true"

{code}
Results in something similar to:
{noformat}
[Pipeline] echo


Running powershell command:
buildVS 'Release' -nuget $true

  
[Pipeline] powershellpowershell powershell
powershell
.exe : buildVS : Cannot process command because of one or more missing mandatory parameters: config.
At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git branch@tmp\durable-
d4ee0605 9137f721 \powershellWrapper.ps1:3 char:1

+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (buildVS : Canno...meters: config.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

At C:\jenkins_workspace\Jenkins Playground\WebAppTest - Deploy from Git
branch@tmp\durable- d4ee0605 9137f721 \powershellScript.ps1:3 char:5

+ buildVS 'Release' -nuget $true

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: ( :) [buildVS], ParameterBindingException

+ FullyQualifiedErrorId : MissingMandatoryParameter,buildVS

[Pipeline] echo
Powershell exit status: 0
{noformat}
 

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:36:02 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss commented on Bug JENKINS-59529
 
Re: Build is not failing when powershell script exits with "MissingMandatoryParameter" or "CommandNotFoundException"

According to [this answer on SO|https://stackoverflow.com/a/34853488/848668,] the script should be exiting with an exit code of 1 when  the -NonInteractive flag is used.  At least in the case of MissingMandatoryParameter.

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:38:02 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss edited a comment on Bug JENKINS-59529
{{According to [this answer on SO|[https://stackoverflow.com/a/34853488/848668] , ]   , the script should be exiting with an exit code of 1 when  the -NonInteractive flag is used.  At least in the case of MissingMandatoryParameter.}}

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:38:02 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss edited a comment on Bug JENKINS-59529
{{According to [ }}{{ this answer on SO }}{{ | }}{{ [https://stackoverflow.com/a/34853488/848668] }}{{ ], the script should be exiting with an exit code of 1 when  the -NonInteractive flag is used.  At least in the case of MissingMandatoryParameter.}}

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 25, 2019, 8:39:02 PM9/25/19
to jenkinsc...@googlegroups.com
Brent Zeiss edited a comment on Bug JENKINS-59529
{{ According to [ }}{{ this answer on SO }}{{ | }}{{[ https://stackoverflow.com/a/34853488/848668] }}{{] , the script should be exiting with an exit code of 1 when  the {{ -NonInteractive }} flag is used.  At least in the case of  {{ MissingMandatoryParameter . }} .

brent.jacobs@zeiss.com (JIRA)

unread,
Sep 26, 2019, 12:29:05 AM9/26/19
to jenkinsc...@googlegroups.com

Alright, just discovered some odd behavior.

If the Stdout is returned, then the script will fail as expected...

I would expect both to return a postive exit code!

The downside of using returnStdout is that none of that output will be displayed in the logs.

pipeline {
    agent any
    stages {
        stage('gobbledygook - will pass') {
            steps{
                powershell script: 'gobbledygook'
            }
        }
        stage('gobbledygook - will fail') {
            steps{
                powershell returnStdout: true, script: 'gobbledygook'
            }
        }
    }
}

And this is the output:

[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\jenkins_workspace\Jenkins Playground\PowershellErrorExample
[Pipeline] {
[Pipeline] stage
[Pipeline] { (gobbledygook - will pass)
[Pipeline] powershell
powershell.exe : gobbledygook : The term 'gobbledygook' is not recognized as the name of a cmdlet, function, script file, or operable 
At C:\jenkins_workspace\Jenkins Playground\PowershellErrorExample@tmp\durable-805172ca\powershellWrapper.ps1:3 char:1
+ & powershell -NoProfile -NonInteractive -ExecutionPolicy Bypass -Comm ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (gobbledygook : ...e, or operable :String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\jenkins_workspace\Jenkins Playground\PowershellErrorExample@tmp\durable-805172ca\powershellScript.ps1:1 char:1

+ gobbledygook

+ ~~~~~~~~~~~~

    + CategoryInfo          : ObjectNotFound: (gobbledygook:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

 

[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (gobbledygook - will fail)
[Pipeline] powershell
gobbledygook : The term 'gobbledygook' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify 
that the path is correct and try again.
At C:\jenkins_workspace\Jenkins Playground\PowershellErrorExample@tmp\durable-bf7e742d\powershellScript.ps1:1 char:1
+ gobbledygook
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (gobbledygook:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
 

[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
Reply all
Reply to author
Forward
0 new messages