【问题标题】:Jenkins DSL : Job SLack publisher : baseUrl() method not availableJenkins DSL:Job Slack 发布者:baseUrl() 方法不可用
【发布时间】:2018-01-24 12:25:24
【问题描述】:

我使用 Jenkins 2.63 和 Slack Notifier 插件 2.2

我需要通过 Job DSL 使用 SlackNotifier 生成作业,但我无法在 DSL 中设置 Base URL,我收到以下消息:

错误:(脚本,第 145 行)没有方法签名:baseUrl() 适用于参数类型:(java.lang.String) 值:[https://my.domain.slack.com/services/hooks/jenkins-ci/] 可能的解决方案:authToken( ), authTokenCredentialId(), botUser(), commitInfoChoice(), customMessage(), includeCustomMessage(), includeTestSummary(), notifyAborted(), notifyBackToNormal(), notifyFailure(), notifyNotBuilt(), notifyRegression(), notifyRepeatedFailure(), notifySuccess(), notifyUnstable(), room(), sendAs(), startNotification(), teamDomain() 完成:失败

这是我的 DSL 脚本

        publishers  {
          def slackParam = new groovy.json.JsonSlurper().parse(new File(channelFile))

          slackNotifier {
            baseUrl(slackParam.url)
            authTokenCredentialId(slackParam.authTokenCredentialId) 
            includeTestSummary(true) 
            notifyAborted(true) 
            notifyBackToNormal(true) 
            notifyFailure(true) 
            notifyNotBuilt(true) 
            notifyRegression(true) 
            notifyRepeatedFailure(true) 
            notifyUnstable(true)
            room(slackParam.room) 
          }
        }

但是在job config.xml中我可以找到这个参数。

谁能帮我设置基本 URL 参数?

非常感谢。

【问题讨论】:

    标签: jenkins dsl slack


    【解决方案1】:

    使用配置块:https://github.com/jenkinsci/job-dsl-plugin/wiki/The-Configure-Block

      configure { project ->
        project / publishers << 'jenkins.plugins.slack.SlackNotifier' {
          baseUrl("https://whatever.slack.com/services/hooks/jenkins-ci/")
          room("#room")
          notifyAborted(true)
          notifyFailure(true)
          notifyNotBuilt(false)
          notifyUnstable(true)
          notifyBackToNormal(true)
          notifySuccess(true)
          notifyRepeatedFailure(false)
          startNotification(false)
          includeTestSummary(false)
          includeCustomMessage(true)
          customMessage("Environment")
          sendAs(null)
          commitInfoChoice("AUTHORS_AND_TITLES")
          teamDomain("yourDomain")
          authTokenCredentialId("token")
        }
      }
    

    把它放在你工作底部的步骤之外。您应该会在作业的 UI 和 config.xml 中看到反映的更改。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多