RE: Declarative script: 'bat' command fails but job succeeds

2017-10-19 Thread David Aldrich
Thanks for your answer.

From: jenkinsci-users@googlegroups.com 
[mailto:jenkinsci-users@googlegroups.com] On Behalf Of jer...@bodycad.com
Sent: 19 October 2017 15:36
To: Jenkins Users <jenkinsci-users@googlegroups.com>
Subject: Re: Declarative script: 'bat' command fails but job succeeds

Not sure about declarative pipeline (I haven't played with them yet). but for 
normal pipeline I use it this way:
bat returnStatus: false, script: "\"${bcad.msbuild_current}\" 
${bcad.msbuild_solution_name} ${bcad.msbuild_default_arg} /t:Build"

You can find the doc here:
https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#bat-windows-batch-script

returnStatus can be check or not if you want, if you don't want to end the 
script for warnings like my above example. You can then use msbuild parser for 
example
step([$class: 'WarningsPublisher', canRunOnFailed: true, consoleParsers: 
[[parserName: 'MSBuild']]])

--
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
jenkinsci-users+unsubscr...@googlegroups.com<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0e30d94d-ccfc-4b72-b8a8-a7280ee99ce5%40googlegroups.com<https://groups.google.com/d/msgid/jenkinsci-users/0e30d94d-ccfc-4b72-b8a8-a7280ee99ce5%40googlegroups.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.


Click 
here<https://www.mailcontrol.com/sr/Nq88hfq4QFrGX2PQPOmvUiOFufhVdryL!w9pVUTemXJrgzmUvReValbza45QkcfmBzPeXKV5M07IiTKH8SslWQ==>
 to report this email as spam.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b24f8f98fef84fdeb8f879b5f8d33ac7%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Declarative script: 'bat' command fails but job succeeds

2017-10-19 Thread jerome
Not sure about declarative pipeline (I haven't played with them yet). but 
for normal pipeline I use it this way:
bat returnStatus: false, script: "\"${bcad.msbuild_current}\" 
${bcad.msbuild_solution_name} ${bcad.msbuild_default_arg} /t:Build"

You can find the doc here:
https://jenkins.io/doc/pipeline/steps/workflow-durable-task-step/#bat-windows-batch-script

returnStatus can be check or not if you want, if you don't want to end the 
script for warnings like my above example. You can then use msbuild parser 
for example
step([$class: 'WarningsPublisher', canRunOnFailed: true, consoleParsers: [[
parserName: 'MSBuild']]])

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0e30d94d-ccfc-4b72-b8a8-a7280ee99ce5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Declarative script: 'bat' command fails but job succeeds

2017-10-19 Thread David Aldrich
Thanks very much for your reply.

> Take care batch error level only is valid for the last command and not a 
> cumulative flag.

Yes, that was exactly the issue.  I followed your advice and the script works 
correctly now.

> Also make sure you give the proper  bat argument returnStatus into your 
> pipeline scripts.

I partly understand this. Where should I specify the returnStatus argument? 
(Note this is declarative).

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0b9060410d0947cea65a8179587d983b%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Declarative script: 'bat' command fails but job succeeds

2017-10-18 Thread jerome
Take care batch error level only is valid for the last command and not a 
cumulative flag. So every msbuild command you run should check the error 
level result and exit batch according to it with proper error code. This 
will make the bat command failed properly. I personnaly would suggest, you 
run run each msbuild command into separated bat command so you will known 
which one failed, but that's totally up to you. Also make sure you give the 
proper  bat argument returnStatus into your pipeline scripts.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8b5daca4-a072-4d1e-b06d-fcd4aeefb356%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Declarative script: 'bat' command fails but job succeeds

2017-10-18 Thread David Aldrich
Yes, that’s right. Sorry for using wrong term.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8b9b98ea15b74577a831c9c047117c57%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Declarative script: 'bat' command fails but job succeeds

2017-10-18 Thread itchymuzzle
So you don't mean "script", you mean using "bat" as you would "sh".   Is 
that right?

stage('Build') {
steps {
script {

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/8786d351-6da3-4b01-8b78-c786cdbd869a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Declarative script: 'bat' command fails but job succeeds

2017-10-18 Thread David Aldrich
Here’s a better view of my script:

pipeline {

agent none
options { buildDiscarder(logRotator(numToKeepStr: '20')) }
triggers {
pollSCM('H/5 * * * *')
}

stages {

stage('build_gcc') {

}

stage('build_VisualStudio') {

agent { label "jenkinswin10" }

environment {
VSMSBUILDCMD = 'C:\\Program Files (x86)\\Microsoft Visual 
Studio 14.0\\Common7\\Tools\\VsMSBuildCmd.bat'
}

steps {
bat '''
call "%VSMSBUILDCMD%"
msbuild %WORKSPACE%\\MSVC\\myproj.sln 
/p:Configuration=Release /p:Platform="Win32" /flp:logfile=ZodiacOutput.log 
/verbosity:normal
'''
}

post {

}
}
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/9ba563a7d91948fbbd59f4b9915c7174%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.


Re: Declarative script: 'bat' command fails but job succeeds

2017-10-18 Thread itchymuzzle
>bat '''

What type of quote(s) is that?  Three single quotes?

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/5d396552-7017-4ba9-85bb-eca78abebe6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Declarative script: 'bat' command fails but job succeeds

2017-10-18 Thread itchymuzzle
Where is "script" in the original example?

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/646ef4ba-2200-46ed-b6b1-fb6938984104%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: Declarative script: 'bat' command fails but job succeeds

2017-10-18 Thread David Aldrich
A follow-up to this:

I ran the failing msbuild command from the command line (in the workspace) and 
checked the errorlevel, it was 1.

I then replayed the declarative script with some extra code:

msbuild %WORKSPACE%\\MSVC\\ /p:Configuration=config_2 /p:Platform="Win32" 
/flp:logfile=ZodiacOutput.log /verbosity:normal
if errorlevel 1 (
   echo Failure Reason Given is %errorlevel%
   exit /b %errorlevel%
)

The Jenkins output was then:

Failure Reason Given is 1
Post stage
[Pipeline] script
[Pipeline] {

[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE

So I had to explicitly check the errorlevel to detect the failure. Does this 
mean there is this a bug in the declarative script plugin?

Best regards

David

From: jenkinsci-users@googlegroups.com 
[mailto:jenkinsci-users@googlegroups.com] On Behalf Of David Aldrich
Sent: 18 October 2017 10:45
To: jenkinsci-users@googlegroups.com
Subject: [** SUSPICIOUS EMAIL **] Declarative script: 'bat' command fails but 
job succeeds

Hi

I have a declarative script that runs a ‘bat’ step. That step builds some VS 
Studio projects on a Windows slave by calling msbuild:

steps {
bat '''
call "%VSMSBUILDCMD%"

msbuild %WORKSPACE%\\MSVC\\ /p:Configuration=config_0 
/p:Platform="Win32" /flp:logfile=Output.log /verbosity:normal

msbuild %WORKSPACE%\\MSVC\\ /p:Configuration=config_1 
/p:Platform="Win32" /flp:logfile=Output.log /verbosity:normal

msbuild %WORKSPACE%\\MSVC\\ /p:Configuration=config_2 
/p:Platform="Win32" /flp:logfile=Output.log /verbosity:normal

'''
}

The second msbuild command is failing (due to missing header files) and reports 
‘Build Failed’, but the script step succeeds and the post stage executes the 
‘success’ code.

Any idea why the step is not failing please?

Best regards

David



Click 
here<https://www.mailcontrol.com/sr/Vzuf+HRUf8PGX2PQPOmvUu5zZAYN1MosnTW3zhZKWbhh!Dytlro2e7hn8lMwcsgKRrt8KGK6VIJzr!jqbv!p6A==>
 to report this email as spam.
--
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
jenkinsci-users+unsubscr...@googlegroups.com<mailto:jenkinsci-users+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b1500615c71c4a48b48714a3a1aa3706%40EUX13SRV1.EU.NEC.COM<https://groups.google.com/d/msgid/jenkinsci-users/b1500615c71c4a48b48714a3a1aa3706%40EUX13SRV1.EU.NEC.COM?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/c2e2bae1aa964ce09bff3f891cd4d508%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.


Declarative script: 'bat' command fails but job succeeds

2017-10-18 Thread David Aldrich
Hi

I have a declarative script that runs a 'bat' step. That step builds some VS 
Studio projects on a Windows slave by calling msbuild:

steps {
bat '''
call "%VSMSBUILDCMD%"

msbuild %WORKSPACE%\\MSVC\\ /p:Configuration=config_0 
/p:Platform="Win32" /flp:logfile=Output.log /verbosity:normal

msbuild %WORKSPACE%\\MSVC\\ /p:Configuration=config_1 
/p:Platform="Win32" /flp:logfile=Output.log /verbosity:normal

msbuild %WORKSPACE%\\MSVC\\ /p:Configuration=config_2 
/p:Platform="Win32" /flp:logfile=Output.log /verbosity:normal

'''
}

The second msbuild command is failing (due to missing header files) and reports 
'Build Failed', but the script step succeeds and the post stage executes the 
'success' code.

Any idea why the step is not failing please?

Best regards

David

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/b1500615c71c4a48b48714a3a1aa3706%40EUX13SRV1.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.