首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GitHub拉取请求构建器DSL groovy语法不起作用

GitHub拉取请求构建器DSL groovy语法不起作用
EN

Stack Overflow用户
提问于 2016-09-26 22:01:07
回答 1查看 993关注 0票数 0

我正在尝试使用DSL脚本为GitHub拉取请求构造器创建Jenkins作业,但我的groovy脚本给出了错误,如果我使用的语法不正确,请更正我的代码。

代码语言:javascript
复制
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')
  }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-09-27 02:41:15

您只能在配置块中使用Configure Block语法:

代码语言:javascript
复制
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')
    }
  }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39704959

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档