Revision: 70500
Updated Code
at March 9, 2016 04:17 by 4fthawaiian
Updated Code
import com.atlassian.jira.ComponentManager import com.atlassian.jira.project.ProjectManager import com.atlassian.jira.project.Project import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import groovy.json.JsonBuilder import groovy.transform.BaseScript import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.core.Response @BaseScript CustomEndpointDelegate delegate updateLead( httpMethod: "GET", groups: ["jira-administrators"] ) { MultivaluedMap queryParams, String body -> ComponentManager componentManager = ComponentManager.getInstance() ProjectManager projectManager = componentManager.getProjectManager() String userToElevate String projectToFind Project theProject try { userToElevate = queryParams.get("userName")[0].toString() } catch(java.lang.NullPointerException e) { return Response.serverError().entity([error: "please supply userName"]).build(); } try { projectToFind = queryParams.get("projectKey")[0].toString() } catch(java.lang.NullPointerException e) { return Response.serverError().entity([error: "please supply projectKey"]).build(); } try { theProject = projectManager.getProjectObjByKey(projectToFind) } catch(java.lang.NullPointerException e) { return Response.serverError().entity([error: "couldn't find project \"$projectToFind\""]).build(); } String projName = theProject.getName() String projDesc = theProject.getDescription() Long projAssignee = theProject.getAssigneeType() String projUrl = theProject.getUrl() Project updatedProject = projectManager.updateProject(theProject, projName, projDesc, userToElevate, projUrl, projAssignee ) return Response.ok(new JsonBuilder([userName: "$userToElevate"]).toString()).build() }
Revision: 70499
Updated Code
at March 9, 2016 04:15 by 4fthawaiian
Updated Code
import com.atlassian.jira.ComponentManager import com.atlassian.jira.project.ProjectManager import com.atlassian.jira.project.Project import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import groovy.json.JsonBuilder import groovy.transform.BaseScript import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.core.Response @BaseScript CustomEndpointDelegate delegate updateLead( httpMethod: "GET", groups: ["jira-administrators"] ) { MultivaluedMap queryParams, String body -> ComponentManager componentManager = ComponentManager.getInstance() ProjectManager projectManager = componentManager.getProjectManager() String userToElevate String projectToFind try { userToElevate = queryParams.get("userName")[0].toString() } catch(java.lang.NullPointerException e) { return Response.serverError().entity([error: "please supply userName"]).build(); } try { projectToFind = queryParams.get("projectKey")[0].toString() } catch(java.lang.NullPointerException e) { return Response.serverError().entity([error: "please supply projectKey"]).build(); } try { Project theProject = projectManager.getProjectObjByKey(projectToFind) } catch(java.lang.NullPointerException e) { return Response.serverError().entity([error: "couldn't find project \"$projectToFind\""]).build(); } String projName = theProject.getName() String projDesc = theProject.getDescription() Long projAssignee = theProject.getAssigneeType() String projUrl = theProject.getUrl() Project updatedProject = projectManager.updateProject(theProject, projName, projDesc, userToElevate, projUrl, projAssignee ) return Response.ok(new JsonBuilder([userName: "$userToElevate"]).toString()).build() }
Revision: 70498
Updated Code
at March 8, 2016 11:38 by 4fthawaiian
Updated Code
import com.atlassian.jira.ComponentManager import com.atlassian.jira.project.ProjectManager import com.atlassian.jira.project.Project import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import groovy.json.JsonBuilder import groovy.transform.BaseScript import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.core.Response @BaseScript CustomEndpointDelegate delegate updateLead( httpMethod: "GET", groups: ["jira-administrators"] ) { MultivaluedMap queryParams, String body -> ComponentManager componentManager = ComponentManager.getInstance() ProjectManager projectManager = componentManager.getProjectManager() String userToElevate String projectToFind try { userToElevate = queryParams.get("userName")[0].toString() } catch(java.lang.NullPointerException e) { return Response.serverError().entity([error: "please supply userName"]).build(); } try { projectToFind = queryParams.get("projectKey")[0].toString() } catch(java.lang.NullPointerException e) { return Response.serverError().entity([error: "please supply projectKey"]).build(); } Project theProject = projectManager.getProjectObjByKey(projectToFind) String projName = theProject.getName() String projDesc = theProject.getDescription() Long projAssignee = theProject.getAssigneeType() String projUrl = theProject.getUrl() Project updatedProject = projectManager.updateProject(theProject, projName, projDesc, userToElevate, projUrl, projAssignee ) return Response.ok(new JsonBuilder([userName: "$userToElevate"]).toString()).build() }
Revision: 70497
Updated Code
at March 8, 2016 11:21 by 4fthawaiian
Updated Code
import com.atlassian.jira.ComponentManager import com.atlassian.jira.project.ProjectManager import com.atlassian.jira.project.Project import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import groovy.json.JsonBuilder import groovy.transform.BaseScript import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.core.Response @BaseScript CustomEndpointDelegate delegate updateLead( httpMethod: "GET", groups: ["jira-administrators"] ) { MultivaluedMap queryParams, String body -> ComponentManager componentManager = ComponentManager.getInstance() ProjectManager projectManager = componentManager.getProjectManager() String userToElevate = queryParams.get("userName")[0].toString() String projectToFind = queryParams.get("projectKey")[0].toString() Project theProject = projectManager.getProjectObjByKey(projectToFind) String projName = theProject.getName() String projDesc = theProject.getDescription() Long projAssignee = theProject.getAssigneeType() String projUrl = theProject.getUrl() Project updatedProject = projectManager.updateProject(theProject, projName, projDesc, userToElevate, projUrl, projAssignee ) return Response.ok(new JsonBuilder([userName: "$userToElevate"]).toString()).build() }
Revision: 70496
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 8, 2016 10:53 by 4fthawaiian
Initial Code
import com.atlassian.jira.ComponentManager import com.atlassian.jira.project.ProjectManager import com.atlassian.jira.project.Project; import com.atlassian.jira.bc.project.component.ProjectComponent; import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate import groovy.json.JsonBuilder import groovy.transform.BaseScript import javax.ws.rs.core.MultivaluedMap import javax.ws.rs.core.Response @BaseScript CustomEndpointDelegate delegate updateLead( httpMethod: "GET", groups: ["jira-administrators"] ) { MultivaluedMap queryParams, String body -> ComponentManager componentManager = ComponentManager.getInstance() ProjectManager projectManager = componentManager.getProjectManager() Project theProject = projectManager.getProjectObjByKey("FP") as Project String userToElevate = queryParams.get("userName")[0].toString() // get the username to be assigned as lead from the query params ("newLead") // then update the project // ProjectManager.updateProject(Project originalProject, // String name, // String description, String leadKey, String url, Long assigneeType) String projName = theProject.getName() String projDesc = theProject.getDescription() Long projAssignee = theProject.getAssigneeType() Project updatedProject = ProjectManager.updateProject(theProject, projName, "a description", userToElevate, "http://example.com", projAssignee ) return Response.ok(new JsonBuilder([userName: "$userToElevate"]).toString()).build() }
Initial URL
Initial Description
after this is added into the custom REST endpoints for scriptrunner, you can run it this way: /rest/scriptrunner/latest/custom/updateLead?userName=USERNAME&projectKey=PROJECTKEY
Initial Title
change lead of jira project using scriptrunner custom endpoint
Initial Tags
Initial Language
Groovy