3
爲了讓我的jenkins管道定義文件更具可定製性,我嘗試使用最大的變量。jenkins管道中的變量
當我嘗試在郵件或步指令詹金斯使用變量拋出此錯誤:
java.lang.NoSuchMethodError: No such DSL method '$' found among [archive, bat, build, catchError, checkout, deleteDir, dir, echo, emailext, emailextrecipients, error, fileExists, git, input, isUnix, load, mail, node, parallel, properties, pwd, readFile, readTrusted, retry, sh, sleep, stage, stash, step, svn, timeout, timestamps, tool, unarchive, unstash, waitUntil, withCredentials, withEnv, wrap, writeFile, ws]
這是我的詹金斯pipleline定義文件:
#!groovy
node {
//Define job context constants
def projectName = "JenkinsPipelineTest"
def notificationEmailRecipients = "[email protected]"
def notificationEmailSender = "[email protected]"
currentBuild.result = "SUCCESS"
//Handle error that can occur in every satge
try {
//Some others stage...
stage 'Finalization'
step([$class: 'ArtifactArchiver', artifacts: '*.zip, *.tar, *.exe, *.html', excludes: null])
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: ${notificationEmailRecipients}, sendToIndividuals: false])
}
catch (err) {
//Set built state to error
currentBuild.result = "FAILURE"
//Send error notification mail
mail body: ${err},
charset: 'UTF-8',
from: ${notificationEmailSender},
mimeType: 'text/plain',
replyTo: ${notificationEmailSender},
subject: '"${projectName}" meet an error',
to: ${notificationEmailRecipients}
throw err
}
}
這是正常的,或者它我的定義文件中有錯誤嗎?