我正在尝试使用DSL脚本创建GitHub Pull Request builder的Jenkins作业,但我的groovy脚本给出错误,请纠正我的代码,如果我使用不正确的语法。
githubPullRequest {
admin('user_1')
admins(['user_2', 'user_3'])
userWhitelist('you@you.com')
userWhitelist(['me@me.com', 'they@they.com'])
orgWhitelist('my_github_org')
orgWhitelist(['your_github_org', 'another_org'])
cron('H/5 * * * *')
triggerPhrase('OK to test')
onlyTriggerPhrase()
useGitHubHooks()
permitAll()
autoCloseFailedPullRequests()
allowMembersOfWhitelistedOrgsAsAdmin()
extensions {
commitStatus {
context('deploy to staging site')
triggeredStatus('starting deployment to staging site...')
startedStatus('deploying to staging site...')
statusUrl('http://mystatussite.com/prs')
completedStatus('SUCCESS', 'All is well')
completedStatus('FAILURE', 'Something went wrong. Investigate!')
completedStatus('ERROR', 'Something went really wrong. Investigate!')
}
it / triggers / 'org.jenkinsci.plugins.ghprb.GhprbTrigger' / extensions / 'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus' / messages << 'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
message('All tests passed!')
result('SUCCESS')
}
it / triggers / 'org.jenkinsci.plugins.ghprb.GhprbTrigger' / extensions / 'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus' / messages << 'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
message('An unknown error occurred.')
result('ERROR')
}
}
只能在Configure块中使用Configure块语法:
job('example') {
triggers {
githubPullRequest {
admin('user_1')
userWhitelist('you@you.com')
orgWhitelist('my_github_org')
cron('H/5 * * * *')
triggerPhrase('OK to test')
extensions {
commitStatus {
context('deploy to staging site')
triggeredStatus('starting deployment to staging site...')
startedStatus('deploying to staging site...')
statusUrl('http://mystatussite.com/prs')
completedStatus('SUCCESS', 'All is well')
completedStatus('FAILURE', 'Something went wrong. Investigate!')
completedStatus('ERROR', 'Something went really wrong. Investigate!')
}
}
}
}
configure {
def messages = it / triggers / 'org.jenkinsci.plugins.ghprb.GhprbTrigger' / extensions / 'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildStatus' / messages
messages << 'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
message('All tests passed!')
result('SUCCESS')
}
messages << 'org.jenkinsci.plugins.ghprb.extensions.comments.GhprbBuildResultMessage' {
message('An unknown error occurred.')
result('ERROR')
}
}
}