0

I have a jenkins step defined like this:

script {
        def cmd =  ' & "' + env.WORKSPACE + '\\SpearsLoad\\Scripts\\DeploySSISPackage.Ps1 -server ' + dbServer + ' -ProjectFilePath ' + env.WORKSPACE + '\\SpearsLoad\\bin\\' + buildConfig + '\\SpearsLoad.ispac"'
        println cmd
        def msg = powershell(returnStdout: true, script: ' & "' + env.WORKSPACE + '\\SpearsLoad\\Scripts\\DeploySSISPackage.Ps1 -server ' + dbServer + ' -ProjectFilePath ' + env.WORKSPACE + '\\SpearsLoad\\bin\\' + buildConfig + '\\SpearsLoad.ispac"')
        println msg
        }

at println cmd I get exactly the powershell i want:

c:\workspace\Spears_master\SpearsLoad\Scripts\DeploySSISPackage.Ps1 -server LONSQLLD01\L14D1 -ProjectFilePath c:\workspace\Spears_master\SpearsLoad\bin\development\SpearsLoad.ispac

I tried inserting the expression in the powershell command:

 powershell(returnStdout: true, script: ' & "' + env.WORKSPACE + '\\SpearsLoad\\Scripts\\DeploySSISPackage.Ps1 -server ' + dbServer + ' -ProjectFilePath ' + env.WORKSPACE + '\\SpearsLoad\\bin\\' + buildConfig + '\\SpearsLoad.ispac"')

which fails as does using the variable

powershell(returnStdout: true, script: cmd)

In both cases I get: is not recognized as the name of a cmdlet, function, script file, or operable program.

It feels like an escaping problem but I am lost - can anyone point me in the right direction

1
  • 1
    Can you ppst the output of your print instruction println msg Commented Mar 12, 2019 at 13:36

1 Answer 1

2

The ampersand & "somecommand" <arguments> pattern is typically used in powershell when somecommand contains spaces.

Note how the arguments are not supposed to be inside the double quotes like in your example. By putting arguments within the quotes, you are forcing powershell to interpret the arguments as being part of the command name, which will not work.

Sign up to request clarification or add additional context in comments.

1 Comment

Thats it env.WORKSPACE + '\\SpearsLoad\\Scripts\\DeploySSISPackage.Ps1 -server ' + dbServer + ' -ProjectFilePath ' + env.WORKSPACE + '\\SpearsLoad\\bin\\' + buildConfig + '\\SpearsLoad.ispac' works thanks :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.