Issue
After that mouthful of a title here comes my snag:
I have a Jenkins system based on JaC. Using Gradle-Dropwizard and Skipper to manage job creation, pipelines etc. I'm trying to implement the Jenkins Notifications plugin with it but i can't get it to work. Tried the official site, the guides(usual and free style job) and the few related questions here but nothing works.
I know it needs to be added under publishers {}
but node(){}
nor steps(){}
work.
it always fails in the DSL creation script under a variation of this:
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)
Has anyone got a clue what to do?
Solution
You can access the full DSL documentation on your own Jenkins server at the following link:
<JENKINS_URL>/plugin/job-dsl/api-viewer/index.html
In the documentation you can search for slack
and see all the available configuration options.
Assuming you are using the Slack Notification Plugin, your configuration can look something alike the following:
freeStyleJob('Slack Notifer') {
// All other configuration
publishers{
slackNotifier {
notifySuccess(true)
customMessage("My Message")
}
}
}
This is the full documentation for the 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)
}
Answered By - Noam Helmer