I am looking at migrating around 75 Projects from an existing Permission scheme into a new Permission scheme. Is there any way to change them in a bulk operation rather than going into each existing project & changing the permission scheme it is associated with?
@Zachary SinghWe have suggestion such as this register to Atlassian so for now you can't do it base on the API. https://jira.atlassian.com/browse/JRACLOUD-37941
but you can try to use this plugin i believe is possible
I don't have the exact query using this plugin yet.
Best!
@Zachary Singh Did you resolve the issue? If yes, please help me out how to do it, I was in the same boat.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Zachary Singh, @niranjan, @Narendra Kumar I am trying to accomplish the same for 100+ projects. Did anyone find an easy solution yet? I read about REST or had the idea of Scriptrunner, but I am not sure that this can be achieved easily.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bernhard Kirschner @niranjan @Zachary Singh I've written script that will help you to change the permission scheme for multiple projects in bulk.
Please find this as -
java.util.ArrayList allProjectKeys = ['A','B','C','D']
for( projKey in allProjectKeys){
def result2 = put('/rest/api/2/project/'+ projKey +'/permissionscheme')
.header('Content-Type', 'application/json')
.body([
id: 111111 // ID for new permission scheme
])
.asString()
}
Run the above script in script-runner . Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you provide me the script that should be working in Scriptrunner?
The above one is not complete I believe?
Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Wim Abts the above script should run. You've to define the ArrayList for your project and just apply the loop and Put call.
First try to run for 4-5 projects to change the permission scheme. Let us know what error you're getting. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is the error I get when running the script in the Scriptrunner console:
2020-11-12 09:07:50,757 ERROR [common.UserScriptEndpoint]: ************************************************************************************* 2020-11-12 09:07:50,757 ERROR [common.UserScriptEndpoint]: Script console script failed: groovy.lang.MissingMethodException: No signature of method: org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.put() is applicable for argument types: (String) values: [/rest/api/2/project/HELP/permissionscheme] Possible solutions: put(java.lang.String, java.lang.Object), get(java.lang.String), putAt(java.lang.String, java.lang.Object), wait(), dump(), any() at Script56.run(Script56.groovy:3)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Here is the working code, folks!! It perfectly works.
*Just copy and paste* in your Script Runner's Script Console. Replace the below Project keys with your list (you can put up to *50 Project keys in one go*.. it processed first 50 keys, when I added 75 keys) and replace the Target Permission Scheme name.
====================
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.project.Project
def list = ["Proj Key 1", "Proj Key 2", "Proj Key 3", "Proj Key 4"]
for(item in list){
def project = ComponentAccessor.getProjectManager().getProjectByCurrentKey(item)
log.warn("Project is:"+project)
String permissionScheme = "Target Permission Scheme"
ComponentAccessor.getPermissionSchemeManager().removeSchemesFromProject(project)
ComponentAccessor.getPermissionSchemeManager().addSchemeToProject(project, ComponentAccessor.getPermissionSchemeManager().getSchemeObject(permissionScheme))
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This really works with latest script runner plugin as well. Is there a way we can pass .txt file in the def list. ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I know this is an old post, but any idea how to update this for cloud?
When I past this in the ScriptRunner console, there is an error message:
"Invalid Imports
It looks like you're trying to import some Java classes intended to work with Jira Server. Unfortunately these won't work due to the differences between Jira Cloud and Jira Server.
ScriptRunner for Jira Cloud is designed to be used with the Jira Cloud REST APIs."
Sorry, but I don't have the knowledge to know how to fix this.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Just wanted to say a big thank you for your script. I just moved 400+ projects to a different permission scheme in about 30mins. This would have taken me hours if I had to do it manually one by one.
Thank you!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Hoc
I have tried that script but its throws me an error "Cannot find matching method".
Using below script in console:
import java.util.ArrayList
import groovy.lang.Closure
import java.lang.String
ArrayList<String> allProjectKeys = new ArrayList<String>();
Arrays.asList('A','B');
for( projKey in allProjectKeys)
{
def result2 = put('/rest/api/2/project/'+ projKey +'/permissionscheme')
.header('Content-Type', 'application/json')
.body([
id::12302]).asString()
}
Error :
------------------------------------------------------------------
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey,
All I did was copy the original script. The only thing I did was add in the project keys and the project id that were unique to my case.
Is that what u did?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hoc,
Yes , earlier I used same code with my project keys and permission scheme ID , same error I got.
After that i have added arrays separately , still same error.
Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Amar Ghag
Apologies I didnt see your response.
I believe you're right. I had to reinstall the app to run the script and it no longer works for me. Although I got a different error message than yourself.
In the past I just replaced the project key and permission scheme id with my one
Perhaps @Narendra Kumar can help you?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Hoc can you ignore it and run the script? Sometimes, static time error won't stop you to do your work .
If this don't work, just change the Arraylist declaration in Groovy.
Let me know how it works for you. Thanks!
Regards,
Narendra
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.