我从Jenkins的文件中运行脚本。命令:
psexec -i -s cmd.exe /c echo . | powershell.exe -file "c:\Program Files (x86)\Applications\Jenkins\jobs\Deploy\workspace\Deploy\script.ps1"
如何传递“build”变量的值?
请帮帮我 感谢
答案 0 :(得分:0)
您只需按照您的参数跟踪路径即可。如:
psexec -i -s cmd.exe /c echo . | powershell.exe -file "c:\Program Files (x86)\Applications\Jenkins\jobs\Deploy\workspace\Deploy\script.ps1" '-build 1.0'
您可以看到PowerShell.exe here的命令行语法。它显示:
PowerShell[.exe]
[-File <FilePath> [<Args>]]
如果这对您不起作用,您可以尝试在脚本块中点源脚本,例如:
psexec -i -s cmd.exe /c echo . | powershell.exe -command {. "c:\Program Files (x86)\Applications\Jenkins\jobs\Deploy\workspace\Deploy\script.ps1" -build 1}
答案 1 :(得分:0)
我在剧本中犯了错误。我忘了插入以下代码:
Param(
[int32]$build=0
)
As TheMadTechnician said,运行脚本的命令是:
psexec -i -s cmd.exe /c echo . | powershell.exe -file "c:\Program Files (x86)\Applications\Jenkins\jobs\Deploy\workspace\Deploy\script.ps1" -build %BUILD_NUMBER%