0
我在Jenkins的文件中運行腳本。命令:PowerShell:傳遞參數
psexec -i -s cmd.exe /c echo . | powershell.exe -file "c:\Program Files (x86)\Applications\Jenkins\jobs\Deploy\workspace\Deploy\script.ps1"
如何傳遞「構建」變量的值?
請幫我 感謝
我在Jenkins的文件中運行腳本。命令:PowerShell:傳遞參數
psexec -i -s cmd.exe /c echo . | powershell.exe -file "c:\Program Files (x86)\Applications\Jenkins\jobs\Deploy\workspace\Deploy\script.ps1"
如何傳遞「構建」變量的值?
請幫我 感謝
我的腳本出錯了。我忘了插入以下代碼:
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%
只需將遵循你的論點的路徑。如:
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>]]
如果不爲你工作,你可以嘗試和點源在-command腳本塊的腳本,如:
psexec -i -s cmd.exe /c echo . | powershell.exe -command {. "c:\Program Files (x86)\Applications\Jenkins\jobs\Deploy\workspace\Deploy\script.ps1" -build 1}
它不會在這種情況下工作( – Pavel 2014-10-01 21:00:47
我在詹金斯還安裝了「PowerShell的插件」並添加了以下命令:。\ Deploy \ script.ps1 -build 1.腳本已完成但構建變量未通過 – Pavel 2014-10-01 21:02:43
添加了一個替代方案,我想PSExec將參數作爲無效參數或某些類似參數切斷。那。 – TheMadTechnician 2014-10-01 21:12:13