Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,121
Community Members
 
Community Events
176
Community Groups

Is it possible to manage an issue's dedicated Slack channel in Scriptrunner scripts?

Edited

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.)

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events