hello,
I have the
slack &
job-dsl plugins installed & configured in my jenkins instance.
I run the seed job for the following my-slack.groovy file:
job("myfolder/myjob") {
steps {
shell("""#!/bin/bash
echo "hello"
""")
}
publishers {
slackNotifier {
room('#jenkins')
notifySuccess(true)
includeCustomMessage(true)
String buildURL = System.getenv("BUILD_URL")
String otherBuildURL = "\$BUILD_URL"
customMessage("BUILD_URL=\$BUILD_URL buildURL={$buildURL} otherBuildURL=${otherBuildURL}")
}
} // publishers
} // job
When I run the job, the notification I receive in my Slack channel has the following text:
BUILD_URL=http://jenkins-ui:8080/job/myfolder/job/myjob/12/ buildURL=null otherBuildURL=http://jenkins-ui:8080/job/myfolder/job/myjob/12/
But what I would like to do is (when
myjob is run - not when the seed job is run) be able to get a copy of
BUILD_URL and edit the copy and include that in
customMessage. Is there any way to do that? (e.g. perhaps with the
Scriptler Plugin?)
e.g. when I add the following code to my-slack.groovy (right after the line where otherBuildURL is initially declared):
otherBuildURL += "console"
then I get this in the Slack notification:
otherBuildURL=$BUILD_URLconsole
To sum this up: what I'm going for is whenever myjob is run, I would like the Slack notification text to include a link to the console output - e.g.:
http://jenkins-ui:8080/job/myfolder/job/myjob/12/console
(Please let me know if I should instead direct this post somewhere else - e.g. the
job-dsl-plugin group.)
Any suggestions would be greatly appreciated. thanks!