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

Next challenges

Recent achievements

Recognition

  • Give kudos
  • My kudos

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

per-project data in a Post Function

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

1 answer

1 accepted

1 vote
Answer accepted

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

How to create Jira issus from Excel file?

When to use CSV importer When managing your processes in Jira, there are many occasions where you need to create a lot of tasks. Creating them one by one will cost you a lot of time and effort and i...

4,623 views 22 33
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you