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

Sample code for retrieving a project metadata

Jaroslav Lhoták Apr 12, 2017

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

 

4 comments

Envitia Oct 18, 2017

Good stuff!

 

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

Jaroslav Lhoták Aug 01, 2018

Thx, not to my knowledge :(

PhillipS Oct 23, 2017

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!!!!!

gfinesch Jul 17, 2018 • edited

Is there a way to write this in java?

PhillipS Jul 30, 2018

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

PhillipS Jul 30, 2018

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

gfinesch Jul 31, 2018

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.

Jaroslav Lhoták Aug 01, 2018

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

positive techno I'm New Here Apr 29, 2019 • edited

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

Comment

Log in or Sign up to comment
Community showcase
Published in Marketplace Apps & Integrations

scaling agile at the enterprise level with Valiantys

Hey there Community! My name is Vannya Vallejo, the Channel Communication Specialist at Atlassian and I want to help Atlassian users like you learn about our Solution Partners and how they can help ...

433 views 1 12
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