GitHub 拉取请求生成器 DSL groovy 语法无效

GitHub pull request builder DSL groovy syntax not working

我正在尝试使用 DSL 脚本为 GitHub Pull Request bulder 创建 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 Block 语法:

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')
    }
  }
}