0

在那满口的标题之后,我的障碍出现了:

我有一个基于 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)

有没有人知道该怎么做?

4

1 回答 1

0

您可以通过以下链接访问您自己的 Jenkins 服务器上的完整 DSL 文档:
<JENKINS_URL>/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)
}
于 2021-08-15T09:25:33.510 回答