Jenkins 作为 Code+Skipper+Gradle-dropwizrd DSL 的松弛通知

Slack notification with Jenkins as Code+Skipper+Gradle-dropwizrd DSL

说了那么多标题之后,我的问题来了:

我有一个基于 JaC 的 Jenkins 系统。使用 Gradle-Dropwizard 和 Skipper 来管理工作创建、管道等。 我正在尝试用它实现 Jenkins Notifications 插件,但我无法让它工作。尝试了官方网站、指南(通常和自由风格的工作)和这里的一些相关问题,但没有任何效果。

我知道它需要添加到 publishers {} 下,但是 node(){}steps(){} 都不起作用。

它总是在以下变体下的 DSL 创建脚本中失败:

No signature of method: javaposse.jobdsl.dsl.jobs.FreeStyleJob.stage() is applicable for argument types: (java.lang.String, script$_run_closure1$_closure2) values: [notify, script$_run_closure1$_closure2@9d55a72]
Possible solutions: wait(), getName(), label(), any(), using(java.lang.String), label(java.lang.String)

有人知道该怎么做吗?

您可以在自己的 Jenkins 服务器上访问完整的 DSL 文档,网址如下link:
/plugin/job-dsl/api-viewer/index.html

在文档中您可以搜索 slack 并查看所有可用的配置选项。
假设您使用的是 Slack Notification Plugin,您的配置可能类似于以下内容:

freeStyleJob('Slack Notifer') {
    // All other configuration
    publishers{
         slackNotifier {
             notifySuccess(true)
             customMessage("My Message")
         }
    }
} 

这是 salckNotifier 的完整文档:

slackNotifier {
     commitInfoChoice(String value)

     // Basedir of the fileset is Fileset ‘includes’ the workspace root.
     artifactIncludes(String value)

     // The slack token to be used to send notifications to Slack.
     authToken(String value)

     // Your Slack-compatible-chat's (e.g.
     baseUrl(String value)

     // Bot user option indicates the token belongs to a custom Slack app bot user in Slack.

     botUser(boolean value)
     // Enter a custom message that will be included with the notifications.

     customMessage(String value)
     customMessageAborted(String value)
     customMessageFailure(String value)
     customMessageNotBuilt(String value)
     customMessageSuccess(String value)
     customMessageUnstable(String value)

     // Choose a custom emoji to use as the bot's icon in Slack, requires using a bot user, e.g.
     iconEmoji(String value)

     includeCustomMessage(boolean value)
     includeFailedTests(boolean value)
     includeTestSummary(boolean value)
     matrixTriggerMode(String value)

     notifyAborted(boolean value)
     notifyBackToNormal(boolean value)
     notifyEveryFailure(boolean value)
     notifyFailure(boolean value)
     notifyNotBuilt(boolean value)
     notifyRegression(boolean value)
     notifyRepeatedFailure(boolean value)
     notifySuccess(boolean value)
     notifyUnstable(boolean value)

     // Enter the channel names or user ids to which notifications should be sent.
     room(String value)

     sendAs(String value)

     // Send message as text as opposed to an attachment.
     sendAsText(boolean value)

     slackUserIdResolver {}
     startNotification(boolean value)

     // Your team's workspace name.
     teamDomain(String value)

     // Token to use to interact with slack.
     tokenCredentialId(String value)

     uploadFiles(boolean value)

     // Choose a custom username to use as the bot's name in Slack, requires using a bot user
     username(String value)
}