簡體   English   中英

jenkins bat命令中powershell的路徑變量

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM