I have a script derived from https://library.adaptavist.com/entity/send-custom-notification-to-slack, but for Microsoft Teams. Works fine when run in ScriptRunner console.
I want to use the script as a Post Function in a workflow that is used by many projects. I want to use a different url for each project, e.g. for an event in Jira project X the script posts to the url for Teams project X', and for an event in Jira project Y the script posts to the url for Teams project Y'.
I was hoping to use a per-project attribute to store the URL, and read it from the post function. But I see from https://community.atlassian.com/t5/Jira-Software-questions/custom-field-in-project-details/qaq-p/1182450 there are no project-level custom attributes. I could keep a table of project-to-url mappings in the script. Are there any good alternatives to doing that?
I'm new to Jira and ScriptRunner.
Thanks,
Greg
You could store the url in the description of each project using some html tag (so that the url doesn't show when viewing the project) and use some string manipulation or regular expression to extract the URL.
Or you could use the OfBizProperty system. But with that, you will need to use some scripting to store the url for each project (not very user-friendly unless you build a UI too).
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.core.ofbiz.util.OFBizPropertyUtils
def project = ComponentAccessor.projectManager.getProjectObjByKey('JSP')
//initialize the properties for a proeject
def properties = OFBizPropertyUtils.getCachingPropertySet('Project',project.id)
//store the property
properties.setString('msteamworks.url', 'https://someteamworksurl.com/')
//retreive a property
def url = properties.getString('msteamworks.url')
Thank you!
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.