有没有办法在PowerShell脚本中使用groovy变量?我的示例脚本如下..
node {
stage('Invoke Installation') {
def stdoutpowershell
def serverName = env.fqdn
withEnv(['serverName = $serverName']) {
echo "serverName : $serverName"
stdoutpowershell = powershell returnStdout: true, script: '''
write-output "Server is $env:serverName"
'''
}
}
答案 0 :(得分:5)
您无法在单引号或三重单引号中插入变量。使用三重双引号:
stdoutpowershell = powershell returnStdout: true, script: """
write-output "Server is $envserverName"
"""