Jenkins和powershell将(数据)视为cmdlet

Jenkins和powershell将(数据)视为cmdlet,powershell,jenkins,Powershell,Jenkins,我有一个Jenkins管道,它使用bat命令运行powershell脚本,该脚本从Jenkins文件传入一些文本 我的Jenkins文件中有参数: daLogNames="Copy Verivo Deployables (data) to Application Directory" 使用该参数的powershell脚本称为: bat "powershell -nologo ./getLogFile.ps1 ${SERENA_TOKEN} ${pipelineParams.daLogName

我有一个Jenkins管道,它使用bat命令运行powershell脚本,该脚本从Jenkins文件传入一些文本

我的Jenkins文件中有参数:

daLogNames="Copy Verivo Deployables (data) to Application Directory"
使用该参数的powershell脚本称为:

bat "powershell -nologo ./getLogFile.ps1  ${SERENA_TOKEN} ${pipelineParams.daLogNames}  %WORKSPACE%/${env.EV_DA_APPNAME}.json"
由于以下消息,Jenkins生成失败:

    data : The term 'data' 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 line:1 char:72
+ ./getLogFile.ps1 **** Copy Verivo Deployables (data) 
to  ...
+                                                                        ~~~~
    + CategoryInfo          : ObjectNotFound: (data:String) [], CommandNotFoun 
   dException
    + FullyQualifiedErrorId : CommandNotFoundException
如何传递数据而不引发错误?如有任何建议,将不胜感激

此文本:daLogNames=Copy Verivo Deployables data to Application Directory直接放在您的bat中,因此它的结果如下:

powershell -nologo ./getLogFile.ps1 SERENA_TOKEN Copy Verivo Deployables (data) to Application Directory c:/workspace/APPNAME.json
数据部分将作为表达式读取,就像您编写的:

write-host 1 + 1 is (1+1)
在其中评估对象。但它无法找到要运行的数据,并抛出一个错误

正如Mathias R.Jessen评论的那样,修复方法是引用所有文本,因此它将作为单个字符串参数传递给PowerShell脚本,例如

bat "powershell -nologo ./getLogFile.ps1  ${SERENA_TOKEN} ""${pipelineParams.daLogNames}""  %WORKSPACE%/${env.EV_DA_APPNAME}.json"
或者可能:

bat "powershell -nologo ./getLogFile.ps1  ${SERENA_TOKEN} '${pipelineParams.daLogNames}' %WORKSPACE%/${env.EV_DA_APPNAME}.json"
${pipelineParams.daLogNames}->${pipelineParams.daLogNames}