Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Listener sprintCreatedEvent only on certain project

Atlassian TMG
April 7, 2023

I would my listener on the sprintCreatedEvent to only be triggered on a certain project. Currently the script below creates a version in a project when there is a sprint created in every project. 

 

{code}

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project

def sprintName = event.sprint.name


def version = ComponentAccessor.versionManager.createVersion(sprintName,
    null,
    null,
    sprintName,
    16400,
    null,false)

    return version.name

{code}

1 answer

Suggest an answer

Log in or Sign up to answer
1 vote
Joshua Yamdogo @ Adaptavist
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 22, 2017

Hi Sar,

Which version of SR and JIRA are you using? This script works fine for me. Have you made sure that you added the validator to the correct workflow step?

Could you try adding a logging statement to see which groups the currentUser is in?

import com.atlassian.jira.component.ComponentAccessor
def groupManager = ComponentAccessor.getGroupManager()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
log.debug(groupManager.getGroupNamesForUser(currentUser))
groupManager.isUserInGroup(currentUser, "Murex Task Team")

 What is output to the log after using this script as a validator?

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 25, 2017

Make sure you are using Simple Scripted Condition, or Simple Scripted Validator.  A screenshot would help.

Sarathi Chatterjee
September 26, 2017

Guys,

I am so sorry for not replying earlier.

The reason it was not working was because I was using Custom script condition  instead of Simple scripted condition.

All good now.
Thank you :)

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
September 26, 2017

Custom script condition should work, except if you're on an old version of the plugin. If you are, you need to set passesCondition to a boolean. Simple scripted condition is easier.

TAGS
AUG Leaders

Atlassian Community Events