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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Set Project Lead with Script Runner

Deleted user Mar 16, 2018

Hello,

 

I trying write code in groovy script runner to create project from post function level in JIRA. Everything going well, but i can't find any solution to change Project Lead for project. I saw that possible is change default assignee, but i can't find any information about Project Lead. Meybe anyone found solution for this. I just need example for specific function. I will be very grateful for help!

Regards,

Wojciech Miecznikowski

1 answer

1 accepted

1 vote
Answer accepted
Deleted user Mar 19, 2018

Big thanks! This is it what i need. I just have problems with implementing this method:

[Static type checking] - Cannot find matching method com.atlassian.jira.project.ProjectManager#updateProject(java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object, java.lang.Object). Please check if the declared type is right and if the method exists. 

Do you have any idea? 

Deleted user Mar 19, 2018

simple example:

import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager

def originalproject = "TESTOR"
def name = "AAA"
def decsription = "test"
def leadkey = "102205"
def assigneeType = "Unassigned"

ProjectManager.updateProject(Project originalProject,Long name,String description,String leadKey,String url,Long assigneeType)

return:

The script could not be compiled:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script808.groovy: 10: The current scope already contains a variable of the name name
 @ line 10, column 59.
   (Project originalProject,Long name,Strin
                                 ^

Script808.groovy: 10: The current scope already contains a variable of the name assigneeType
 @ line 10, column 114.
   tring leadKey,String url,Long assigneeTy
                                 ^

 

If i comment name and assigneetype i got: Cannot find matching mathod

I did not check the code by it must be like this:

import com.atlassian.jira.project.Project
import com.atlassian.jira.project.ProjectManager

import com.atlassian.jira.project.AssigneeTypes

def originalproject = ComponentAccessor.getProjectManager().getPrjectObjByKey("TESTOR")
def name = "AAA"
def decsription = "test"
def leadkey = "username"
def assigneeType = "Unassigned"

ComponentAccessor.getProjectManager().updateProject(originalProject name,description,leadKey, url, AssigneeTypes.UNASSIGNED)

You should provide respect paramteres types.

Deleted user Mar 19, 2018

Thanks! I still learning of groovy. I see that you have small mistake in def of original project. Should be "getProjectManager()" and must have:
"import com.atlassian.jira.component.ComponentAccessor" and "," before name in last line. Anyway. I used a code:

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

def originalproject = ComponentAccessor.getProjectManager().getProjectObjByKey("TESTOR")
def name = "AAA"
def decsription = "test"
def leadkey = "102205" // this is username in my JIRA instance
def assigneeType = "Unassigned"

ComponentAccessor.getProjectManager().updateProject(originalProject,name,description,leadKey,url,assigneeType.UNASSIGNED)

and after run i have:
groovy.lang.MissingPropertyException: No such property: originalProject for class: Script879
at Script879.run(Script879.groovy:12)

Compiler said:

image.png

any idea? 

Yes, the name of variable are different from declaration and passing the the procedure. 

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

def originalproject = ComponentAccessor.getProjectManager().getProjectObjByKey("TESTOR")
def name = "AAA"
def description = "test"
def leadkey = "102205" // this is username in my JIRA instance
def url = "http://google.com"

ComponentAccessor.getProjectManager().updateProject(originalproject,name,description,leadkey,url,assigneeType.UNASSIGNED)
Deleted user Mar 19, 2018

Ok. Foolishly mistakes in declaration... When i trying to use your code i have this:

groovy.lang.MissingPropertyException: No such property: assigneeType for class: Script885 at Script885.run(Script885.groovy:12)

so I change last line like this:

def assigneeType = "102205" as long

ComponentAccessor.getProjectManager().updateProject(originalproject,name,description,leadkey,url,assigneeType)

and Script working but in project i can see "Please select a Default Assignee". It looks that this method have problem with long "Unassigned"? Do you know something about this?

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

def originalproject = ComponentAccessor.getProjectManager().getProjectObjByKey("TESTOR")
def name = "AAA"
def description = "test"
def leadkey = "102205" // this is username in my JIRA instance
def url = "http://google.com"

ComponentAccessor.getProjectManager().updateProject(originalproject,name,description,leadkey,url,AssigneeTypes.UNASSIGNED)
Deleted user Mar 19, 2018

Thank you very much!

I'm sorry to revive this thread, but I have a problem to set the lead.
In my case this is entered as text, but not as recognized user (AD). I have already tried different spelling variants.

What is the solution here?

Hi Tom,

You might need to enter the userid instead of username.

 

Regards,

Nitish

Suggest an answer

Log in or Sign up to answer
TAGS

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