Atlassian's Jira/Slack integration app for Jira Server ("Slack for Jira Server") allows for the creation of dedicated Slack channels for a given issue through the UI. I found a RESTful endpoint that allows assigning a dedicated channel, removing the current dedicated channel, or reading the current dedicated channel via POST, DELETE, and GET calls respectively.
You can do this with the endpoint /rest/slack/latest/dedicatedchannel (just append this to your domain). For GET calls, add the issue key to the path (e.g., /rest/slack/latest/dedicatedchannel/PROJECT-1234). For POST and DELETE calls, pass a JSON object as the request body:
{
"issueKey": "<Jira issue key>",
"teamId": "<Slack team ID>",
"channelId": "<Slack channel ID>"
}
Authentication works exactly the same as any standard Jira REST API call.
However, it would be great if we could automate managing these dedicated Slack channels via Scriptrunner scripts by directly interacting with the Jira/Slack integration plugin itself, which would be more efficient than making a web API call. Poking around in the .jar file, my best guess would be that I need a DedicatedChannelManager, which would provide methods for anything I'm hoping to do.
However, the following code in a script doesn't work, and I otherwise can't figure out where to go from here:
import com.atlassian.jira.plugins.slack.manager.DedicatedChannelManager;
@WithPlugin("com.atlassian.jira.plugins.jira-slack-server-integration-plugin")
@PluginModule
DedicatedChannelManager dedicatedChannelManager;
dedicatedChannelManager.canAssignDedicatedChannel(event.getIssue());
(This script is for a simple Listener -- otherwise, you'll want to get an Issue object some other way, instead of using event.getIssue().
Trying to run this results in the following exception being thrown: "java.lang.Exception: Can't find plugin module or OSGi service for class: com.atlassian.jira.plugins.slack.manager.DedicatedChannelManager, check the plugin is installed / enabled / licensed."
I've tried running code along these lines from the Script Console, from inline scripts, and from scripts in the script root directory -- all result in the same exception.
Any thoughts or guidance? I don't have a lot of experience with scripting other plugins in Scriptrunner, so I'm hoping I'm just making some very basic mistake with the annotations. (I've also tried code that doesn't rely on the annotations, and instead tries to make use of ComponentAccessor, but these have also been unsuccessful. But again, I may have been doing something wrong.)
Just to check were you able to find a solution for this?
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.