Declarative script: How to escape 'Program Files (x86)'?

43 views
Skip to first unread message

David Aldrich

unread,
Apr 18, 2018, 6:28:29 AM4/18/18
to jenkins...@googlegroups.com

My declarative script contains:

 

environment {

      VSMSBUILDCMD_14_0 = 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsMSBuildCmd.bat'

    VSMSBUILDCMD_14_1 = 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\Tools\\VsMSBuildCmd.bat'

}

 

<snip>

 

steps {

    bat '''

        call "%VSMSBUILDCMD_14_1%"

        msbuild <snip>

    '''

 

This results in error:

 

c:\jenkins\workspace\MyJob>call "%C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat%"

\Java\jre1.8.0_161\bin"" was unexpected at this time.

 

I think I need to escape  ‘Program Files (x86)’.  What is the correct syntax for this please?

 

Best regards

 

David

 

Andrew Bayer

unread,
Apr 18, 2018, 10:27:47 AM4/18/18
to jenkins...@googlegroups.com
I'd guess you need to escape the spaces in the original string? I dunno - I don't have a Windows environment handy to test on.

A.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1780c53558db4c81b98ca30e74c2d40a%40EUX13SRV2.EU.NEC.COM.
For more options, visit https://groups.google.com/d/optout.

David Aldrich

unread,
Apr 20, 2018, 3:54:33 AM4/20/18
to jenkins...@googlegroups.com

> I'd guess you need to escape the spaces in the original string?

 

Escaping didn’t help.

 

I’ve posted a complete description of the problem on Stackoverflow:

 

https://stackoverflow.com/questions/49922959/how-to-fix-java-was-unexpected-at-this-time-when-invoking-vs-2017-build-to

 

 

From: jenkins...@googlegroups.com [mailto:jenkins...@googlegroups.com] On Behalf Of Andrew Bayer
Sent: 18 April 2018 15:27
To: jenkins...@googlegroups.com
Subject: Re: Declarative script: How to escape 'Program Files (x86)'?

 

I'd guess you need to escape the spaces in the original string? I dunno - I don't have a Windows environment handy to test on.

 

A.

On Wed, Apr 18, 2018 at 6:28 AM, David Aldrich <David....@emea.nec.com> wrote:

My declarative script contains:

 

environment {

      VSMSBUILDCMD_14_0 = 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\Tools\\VsMSBuildCmd.bat'

    VSMSBUILDCMD_14_1 = 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\Common7\\Tools\\VsMSBuildCmd.bat'

}

 

<snip>

 

steps {

    bat '''

        call "%VSMSBUILDCMD_14_1%"

        msbuild <snip>

    '''

 

This results in error:

 

c:\jenkins\workspace\MyJob>call "%C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat%"

\Java\jre1.8.0_161\bin"" was unexpected at this time.

 

I think I need to escape  ‘Program Files (x86)’.  What is the correct syntax for this 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-use...@googlegroups.com.

 

--

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-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAPbPdOY_r3oGaNMaa9SRYFsSg4QNSPOfWyvA66LLXsQXGZUogA%40mail.gmail.com.


For more options, visit https://groups.google.com/d/optout.

Click here to report this email as spam.

Reply all
Reply to author
Forward
0 new messages