我第一次尝试使用 Jenkins Job DSL 插件来创建一些基本的作业“模板”,然后再进入更复杂的内容。
Jenkins 在 Windows 2012 服务器上运行。 Jenkins 版本是 1.650,我们使用的是 Job DSL 插件版本 1.51。
理想情况下,我希望对种子作业进行参数化,以便在运行时用户可以输入四件事:作业 DSL 脚本位置、生成的作业的名称、用于失败通知的 Slack 通道和电子邮件失败通知的地址。
前两个都很好:我可以调用groovy脚本中的参数,例如脚本理解job("${JOB_NAME}")
并采用我运行种子作业时为作业输入的名称。
然而,当我尝试用 Slack 频道做同样的事情时,groovy 脚本似乎不想播放。请注意,如果我指定 Slack 通道而不是尝试调用参数,它就可以正常工作。
我的工作 DSL 脚本在这里:
job("${JOB_NAME}") {
triggers {
cron("@daily")
}
steps {
shell("echo 'Hello World'")
}
publishers {
slackNotifier {
room("${SLACK_CHANNEL}")
notifyAborted(true)
notifyFailure(true)
notifyNotBuilt(false)
notifyUnstable(true)
notifyBackToNormal(true)
notifySuccess(false)
notifyRepeatedFailure(false)
startNotification(false)
includeTestSummary(false)
includeCustomMessage(false)
customMessage(null)
buildServerUrl(null)
sendAs(null)
commitInfoChoice('NONE')
teamDomain(null)
authToken(null)
}
}
logRotator {
numToKeep(3)
artifactNumToKeep(3)
publishers {
extendedEmail {
recipientList('[email protected] /cdn-cgi/l/email-protection')
defaultSubject('Seed job failed')
defaultContent('Something broken')
contentType('text/html')
triggers {
failure ()
fixed ()
unstable ()
stillUnstable {
subject('Subject')
content('Body')
sendTo {
developers()
requester()
culprits()
}
}
}
}
}
}
}
但是启动种子作业失败并给出以下输出:
Started by user
Building on master in workspace D:\data\jenkins\workspace\tutorial-job-dsl-2
Disk space threshold is set to :5Gb
Checking disk space Now
Total Disk Space Available is: 28Gb
Node Name: master
Running Prebuild steps
Processing DSL script jobBuilder.groovy
ERROR: (jobBuilder.groovy, line 10) No signature of method: javaposse.jobdsl.plugin.structs.DescribableContext.room() is applicable for argument types: (org.codehaus.groovy.runtime.GStringImpl) values: [#dev]
Possible solutions: wait(), find(), dump(), grep(), any(), wait(long)
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE
这是我第一次尝试使用 Groovy 做任何事情,我确信这是一个基本错误,但如果有任何帮助,我将不胜感激。