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}
{code}
The following makes no sense:
def project = ComponentAccessor.projectManager.getProjectByCurrentKey("INTB2BSSD")
if (project.key == 'INTB2BSSD') {
You hardcode a project lookup then check that the project is the one you just hardcoded?
No.
You need to use the information from your event to find your project.
The best way I was able to find to do that is to use the rapidViewId. As far as I know, usually, each rapidVIew (board) should be associated with a single project.
You might need to hardcode that mapping.
For example:
import com.atlassian.greenhopper.api.events.sprint.SprintStartedEvent
event = event as SprintStartedEvent
def boardProjectMap = [
123L: 'PKEY1',
345L: 'PKEY2',
567L: 'PKEY3',
]
def boardId = event.sprint?.rapidViewId
if(!boardId) return //nothing to do if we don't know the board
log.debug "found boardId from the event: $boardId"
def projectKey = boardProjectMap[boardId]
if(!projectKey) return //nothing to do if the board id didn't map to a projectKey
log.debug "found project key $projectKey from boardProjectMap"
def project = ComponentAccessor.projectManager.getProjectObjByKey(projectKey)
the data in boardProjectMap will have to be updated to match your board and project keys
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you please share a screenshot of your listener configuration? I am requesting this to check if you have specified the projects you want the listener to work on in the configuration.
I am looking forward to your feedback.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want the Sprint Listener to trigger for specific Projects only, try adding this filter:-
import com.adaptavist.hapi.jira.projects.Projects
def project = Projects.getByKey('MOCK')
if (project.key == 'MOCK') {
// Your code
}
Please note that the sample code above is not 100% exact to your environment. Hence, you will need to make the required modifications.
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_
I am getting a error.
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: Script660.groovy: 2: unable to resolve class com.adaptavist.hapi.jira.projects.Projects @ line 2, column 1. import com.adaptavist.hapi.jira.projects.Projects ^ 1 error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_ we are currently still using script runner 6.57 and we cannot update intill we are migrated to jira cloud which will take a while.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_ , I changed the script to something similar but didn't work. It still keeps creating versions when a sprint is created in another project.
{code}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I forgot to mention that you need to upgrade your ScriptRunner plugin to the latest rease, i.e. 8.0.0 so you can use the HAPI feature that is shown in the sample code I provided.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Ram Kumar Aravindakshan _Adaptavist_ is there another cmd I can use? Because it's not possible to upgrade at the moment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.