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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,626
Community Members
 
Community Events
184
Community Groups

Scriptrunner CopyProject script does not work properly

Christos Moysiadis
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 Leaders.
Sep 17, 2019
Thread executorThread = new Thread(new Runnable() {
void run() {
def copyProject = new CopyProject()
def inputs = [
(CopyProject.FIELD_SOURCE_PROJECT) : "PR1",
(CopyProject.FIELD_TARGET_PROJECT) : "TEST",
(CopyProject.FIELD_TARGET_PROJECT_NAME) : "TST",
(CopyProject.FIELD_COPY_ISSUES) : true,
(CopyProject.FIELD_COPY_VERSIONS) : true,
(CopyProject.FIELD_COPY_COMPONENTS) : true,
(CopyProject.FIELD_COPY_DASH_AND_FILTERS) : false
]
def errorCollection = copyProject.doValidate(inputs, false)
if(errorCollection.hasAnyErrors()) {
log.error("Couldn't create project: $errorCollection")
}
else {
def util = ComponentAccessor.getUserUtil()
def adminsGroup = util.getGroupObject("jira-administrators")
assert adminsGroup // must have jira-administrators group defined
def admins = util.getAllUsersInGroups([adminsGroup])
assert admins // must have at least one admin
ComponentAccessor.getJiraAuthenticationContext().setLoggedInUser(util.getUserByName(admins.first().name))
copyProject.doScript(inputs)

}
}
})
executorThread.start()

So i have a requirement lately about giving the ability to a limited group of users to copy a template project with the use of this script. Of course there are some more extensions behind it but they are not necessary to mention them currently. 

The current script can copy the project with the name and key correctly. Also the versions and the Components are copied too. I am straggling to find out why it doesn't copy the issues (Yes! the source project has iss.ues in it :P ). 

The jira-administrators group has 2 users . A default defined admin which i have from the install process which has all the permissions.

Jira instance is a pure fresh installed 8.3.2 version (i don't know if this creates the current problem.)

Any ideas my fellow Atlassians & Scriptrunner friends ???? Any workarounds maybe?

Regards

CM

2 answers

1 accepted

0 votes
Answer accepted
Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 20, 2019

Does it work when you run the Copy Project Script from the ScrptRunner UI under Built-In Scripts?

Christos Moysiadis
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 Leaders.
Sep 21, 2019

Basically yes. I even tried this script directly to the console and i have no results! :/

Peter-Dave Sheehan
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Sep 21, 2019

I tried your script (minus the executorThread) in my environment script console with a test project (contains 1 issue) and it worked.

Look in the Audit Log and see who the Author of the changes is. Then perhaps using the built-in script to change the active user to that user and try the built-in copy project script as that user. Are the issues copied?

If not, then look in the source project permissions scheme and make sure that your admin user has browse project and create issue permissions.

Like Christos Moysiadis likes this
Christos Moysiadis
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 Leaders.
Sep 23, 2019

@Peter-Dave Sheehan the funny is that it now works. The even more funnier is that the template project Create Permission was assigned to "Any logged user" . I changed it to the admin user and it seems to work correct now. 

Thnx for your help! :)

Regards

Hi @Christos Moysiadis ,

A concrete solution for this is defined here, https://productsupport.adaptavist.com/browse/SRJIRA-3793

Best Regards,

Gaurav

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events