Синтаксис Groovy DSL построителя запросов на вытягивание GitHub не работает

Я пытаюсь создать задание Jenkins для GitHub Pull Request bulder с помощью DSL-скрипта, но мой groovy-скрипт выдает ошибку, исправьте мой код, если я использую неправильный синтаксис.

githubPullRequest {
        admin('user_1')
        admins(['user_2', 'user_3'])
        userWhitelist('[email protected]')
        userWhitelist(['[email protected]', '[email protected]'])
        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')
  }
}

person Bhushan Phalak    schedule 26.09.2016    source источник


Ответы (1)


Вы можете использовать синтаксис Configure Block только в конфигурации блокировать:

job('example') {
  triggers {
    githubPullRequest {
      admin('user_1')
      userWhitelist('[email protected]')
      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')
    }
  }
}
person daspilker    schedule 26.09.2016