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,557,473
Community Members
 
Community Events
184
Community Groups

Sample code for retrieving a project metadata

First of all thanks Andreas for such nice plugin.

After some hours of trying I made working using Script Runner for getting a metadata ("mykey") from given project ("RISK")

Just want to share it with you this short snippet to save your time, I hope it helps :)

Regards,

Jarda

import com.atlassian.jira.ComponentManager
import com.atlassian.plugin.osgi.container.OsgiContainerManager
import com.atlassian.jira.project.Project
import com.atlassian.jira.component.ComponentAccessor


Project project = ComponentAccessor.getProjectManager().getProjectObjByKey("RISK");

OsgiContainerManager osgiManager = ComponentManager.getInstance().getComponentInstanceOfType(OsgiContainerManager.class)

String x = osgiManager.getServiceTracker("com.osoboo.jira.metadata.MetadataService").getService().getMetadataValue(project, "mykey")

 

5 comments

Good stuff!

 

Do you know if you can get the metadata out using the existing JIRA API?

Thx, not to my knowledge :(

It's' unfortunate that the groovy embedded "compiler" gives  you a potential error in the script, but it works when running a preview on an issue.  Thanks!!!!!

Is there a way to write this in java?

My understanding is that GROOVY script is Java with some "fluff".  And that GROOVY follows almost all, if not all the syntax conventions of JAVA.  Which part isn't working for you the way it's written in groovy

I guess in order to make it work in JAVA you may have to wrap it in a class to get it to execute?

Thanks Phillip. I realized that the metadata plugin is not free anymore so we're not going to install int anymore on the latest Jira version we are upgrading to soon. We are going to use the Project Properties Plugin for Jira as a replacement.

Really? That's the third plugin I remember which used to be free and became paid. Damn it, we run 10k license :( 

Hi Can you please provide the steps in jira how to take the metadata backup using script runner

What would the script be in 8.x since ComponentManager is deprecated?

Andreas Spall _evolu_software_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
May 12, 2021

Hi Margaret, you can also use the dependency injection of jira 

https://aevolu.atlassian.net/wiki/spaces/JM/pages/659816449/How-to+use+our+Java+API

for scriptrunner there is also this page and its subpages 

https://aevolu.atlassian.net/wiki/spaces/JM/pages/656965633/How-to+articles+for+ScriptRunner+for+Jira

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events