![](/img/trans.png)
[英]How to read a variable inside a powershell command written in a .bat file
[英]path variable for powershell in jenkins bat command
我想在Jenkins管道中執行我的powershell腳本。 因此我使用bat
來調用我的.ps1文件
bat 'powershell "C:\\path\\to\\file\\script.ps1"'
在powershell內部,我需要使用特定的路徑。 有沒有辦法通過以下方式提供這條路徑:
bat 'powershell "C:\\path\\to\\file\\script.ps1"' -var PATH
在調用powershell之前在bat步驟中設置環境:
bat """\
set PATH=....
powershell "C:\\path\\to\\file\\script.ps1"
""";
Inside the block you can reference you're pipeline variables with `${varName}`. So:
def myVar = "somePath"
bat """\
set PATH=%PATH%;${somePath}
powershell "C:\\path\\to\\file\\script.ps1"
""";
使用環境變量,如SET "INPT=C:\\\\path\\\\to\\\\file\\\\script.ps1"
,然后在powershell中使用。
不幸的是,在bat命令中不可能使用Pipeline Jobs變量
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.