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

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

Listener to merge the Project ID with created Fix Version Name

Edited

Hey Guys,

 

I'm trying to create a custom listener with the conditions below:

 

Project(s): All projects

Events: VersionCreateEvent

Job/Scenario:  Whenever we create a Version, we need to merge the recently created version with the project ID.

Problem found: I just tried to log the project ID from the created Version, however the class VersionCreateEvent doesn't have Issue and Project as property, also couldn't find any way to get the version event, like event.issue and event.project.

I was able to log the event properties and got the result below

2019-06-24 10:50:25,450 DEBUG [acme.ListLinks]: {class=class com.atlassian.jira.event.project.VersionDeleteEvent, fixVersionSwappedTo=none(), customFieldReplacements=[], version=Teste3, mergedTo=none(), versionId=15412, affectsVersionSwappedTo=none()}

Script:

import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.ListLinks")
log.setLevel(Level.DEBUG)
//-------------------------------------------------------------------------------------------------------------------------------------------

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.project.Project
import com.atlassian.jira.project.version.Version

//Issue issue = event.issue
//Project project = event.project
def event = event.getProperties()

def versionManager = ComponentAccessor.getVersionManager()
def projectManager = ComponentAccessor.getProjectManager()
//def versions = versionManager.getVersions()

log.debug (event)

Errors:

2019-06-24 10:00:21,226 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.project.VersionDeleteEvent, file: <inline script>
groovy.lang.MissingPropertyException: No such property: issue for class: com.atlassian.jira.event.project.VersionDeleteEvent
	at Script4542.run(Script4542.groovy:12)
2019-06-24 10:23:15,780 ERROR [runner.AbstractScriptListener]: Script function failed on event: com.atlassian.jira.event.project.VersionDeleteEvent, file: <inline script>
groovy.lang.MissingPropertyException: No such property: project for class: com.atlassian.jira.event.project.VersionDeleteEvent
	at Script4573.run(Script4573.groovy:12)

 

If anyone has any tip to give, feel free to say and we will give it a shot.

 

Thanks so much in advance.

1 answer

You need to go to docs and check available variants.

For example to get project you need to use such expression

def project = event.version.getProject()

https://docs.atlassian.com/software/jira/docs/api/8.10.1/com/atlassian/jira/project/version/Version.html

For eventclass FixVersionCreatedInline I am not sure that it knows issue parameters.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Apps & Integrations

🍻🍂Apptoberfest Update: Upcoming Virtual Events 🎉

Hello Community! I hope you've been enjoying the 🍂Apptoberfestivities🍂 (I know I have!) The event is heating up next week with a series of virtual events that we're calling the 🍻🍂Partner App ...

151 views 2 13
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