how to get released versions using "getVersionsReleased" method in groovy in Behaviours Plugin?

my jira version is 4.4.1.

i put a validator on "description".and add the validation script below,but the field "description" gets no result.

import com.atlassian.jira.project.version.VersionManager
FormField formDescField=getFieldById("description")

List<VersionManager> versions=getVersionsReleased(10101,true) as List

anyone knows how to use the method "getVersionsReleased"

1 answer

1 accepted

1 vote
Answer accepted

While you’re developing this, you should turn on logging for the Behaviours plugin and check the logs when something goes wrong. In this case, you’d see that your code is throwing exceptions and never even gets to the part where setFormValue is executed.

The problem here is that you can’t just call getVersionsReleased as a bare function. It’s a method of a VersionManager object, but you never got a VersionManager object. You only imported the class, which isn’t enough.

To get the VersionManager object, you can first get the ComponentManager object and call getVersionManager() on it, and to get the ComponentManager object you can import com.atlassian.jira.ComponentManager and call getInstance() on the class. getInstance() is a static function.

(I wish I could point you to some docs on this, but there don’t seem to be any good ones. I had to learn it by puzzling over example code.)

Try this:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.project.version.VersionManager

ComponentManager componentManager = ComponentManager.getInstance()
VersionManager versionManager =  componentManager.getVersionManager()

FormField formDescField=getFieldById("description")
List<VersionManager> versions=versionManager.getVersionsReleased(10101,true) as List


it works using your code.

another question:

you say Behaviours Plugin can i turn on logging for the plugin.

i searched out the JIRA installation location,can only find log files in JIRA\Atlassian\Application Data\JIRA\log.and found three log files:atlassian-jira.log,atlassian-jira-security.log,atlassian-jira-slow-queries.log.

open atlassian-jira.log,i didn't see any error messages about this plugin if i put wrong script into the plugin on purpose.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


203 views 0 5
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you