【发布时间】:2018-05-26 21:43:13
【问题描述】:
我想在 power shell 脚本中使用 jenkins 环境变量。这里 ${destination} 在 powershell 脚本中为 null。无法确定我在做什么。请帮助
# !/bin/groovy
pipeline {
agent {
label {
label ""
customWorkspace "C:\\Jenkins\\workspace"
}
}
environment {
def destination=''
}
options {
timestamps()
timeout(time: 60, unit: 'MINUTES')
skipDefaultCheckout(true)
disableConcurrentBuilds()
}
stages {
stage('TEST')
{
steps {
script{
destination="\\\\SERVERNAME\\d\$"
}
echo "${destination}"
powershell '''
$destinationPath ="${destination}"
write-host $destinationPath
write-host "test3" '''
}
}
}
post {
always {
deleteDir()
}
}
【问题讨论】:
-
不要使用
${destination},而是使用%destination%。 -
%destination%将无法解析。
标签: jenkins jenkins-pipeline declarative