【发布时间】:2020-10-08 18:32:24
【问题描述】:
之前有一些关于将 Jenkins 变量传递到 powershell 脚本的问题。但他们不为我工作。这可能是我运行 powershell 脚本的方式。 这是代码:
steps{
script {
echo "release file name: " + "$env:RELEASE_NAME"
powershell('''
Write-Host "Deploy into WTC production"
Write-Host "Release file: $env:RELEASE_NAME"
$finalPath = $env:RELEASE_NAME
...more powershell statements....
''')
}
echo 语句返回带有版本和 .zip 扩展名的正确文件名 Write-Host 命令为版本名称返回一个空字符串
我尝试将 withEnv([releaseName=$env:RELEASE_NAME]) 添加到 powershell 脚本的顶部,如下所示:
withEnv([releaseName=$env:RELEASE_NAME])
powershell('''
Write-Host "Deploy into WTC production"
Write-Host "Release file: $env:releaseName"
但是由于:.文件无法编译。 如何将 RELEASE_NAME 变量传递到 powershell 脚本?
【问题讨论】:
标签: powershell jenkins