Greetings. I am trying to post to a slack channel when the build succeeds or fails. We have a remote jenkinsfile that defines the shared build steps for all our jobs. I am doing the following:
success {
notifyGitHubStatus(message: "built tag ${env.CP_BUILD_ECR_IMAGE_TAG}", status: "SUCCESS")
script {
def serviceToBuild = builder.findService(env.CP_BUILD_SERVICE_NAME)
if (serviceToBuild.buildConfiguration.slackChannel != null) {
slackSend(channel: serviceToBuild.buildConfiguration.slackChannel, message: "Build success on ${env.CP_BUILD_ECR_IMAGE_TAG} for service ${env.CP_BUILD_SERVICE_NAME}")
}
}
}
however, I am getting the following error:
11:39:52 GMT-04:00 Slack Send Pipeline step running, values are - baseUrl: <empty>, teamDomain: mbonline-team, channel: notify-platform, color: <empty>, botUser: true, tokenCredentialId: jenkins-b2c-token, notifyCommitters: false, iconEmoji: <empty>, username: <empty>, timestamp: <empty>
11:39:52 GMT-04:00 ERROR: Slack notification failed with exception: {"ok":false,"error":"not_in_channel"}
11:39:52 GMT-04:00 ERROR: Slack notification failed. See Jenkins logs for details.
When I go to the channel, I try to do @jenkins but I only get coworkers whose surnames are Jenkins. The app is installed from the app directory, and I can view the config, but it won’t let me invite the bot user. Is there some way I can just let it post to every channel it wants to?