Is it possible to clone an issue using the REST api?
Community moderators have prevented the ability to post new answers.
Not yet. You can probably write a new REST method in a plugin!
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.
JIRA Command Line Interface has some a cloneIssue action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes I saw that, but its cloneIssue action used the companion plugin. Looks like creating a REST module to give me the option through the API shouldnt be too difficult and get me going on plugin development.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The clone action only requires the Clone Plus Plugin for JIRA if you try to use any of the functions that are not supported by the standard clone operation. So, just cloning an issue without setting fields or changing the project/issues will just use the normal clone action.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
With Adaptavist Scriptrunner installed you can define a script endpoint without writing a plugin.
Ours clones custom fields and has some parameters you might want to use or not (coworkerIds). You will easily strip out useless parts of the code below if needed.
// CLONE
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript
import static com.atlassian.jira.component.ComponentAccessor.*
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
@BaseScript CustomEndpointDelegate delegate
clone(httpMethod: "GET") { MultivaluedMap queryParams ->
String issueKey = queryParams.getFirst("issueKey") as String
String assigneeId = queryParams.getFirst("assigneeId") as String
String coworkerIds = queryParams.getFirst("coworkerIds") as String
String summary = queryParams.getFirst("summary") as String
def issue = issueManager.getIssueObject(issueKey)
def clonedIssue = issueFactory.cloneIssue(issue)
if(summary) clonedIssue.summary = summary
if(assigneeId) clonedIssue.assigneeId = assigneeId
if(coworkerIds) {
clonedIssue.setCustomFieldValue(
customFieldManager.getCustomFieldObjectByName("Co-Workers"),
coworkerIds.split('[,\\s]+').collect { userManager.getUserByName(it) }
)
}
customFieldManager.getCustomFieldObjects( issue.projectObject.id, issue.issueTypeObject.id).each {
def value = it.getValue(issue)
if(value) clonedIssue.setCustomFieldValue(it, value)
}
def createdIssue = issueManager.createIssueObject(jiraAuthenticationContext.user, clonedIssue)
def builder = new groovy.json.JsonBuilder()
builder { key createdIssue.key }
return Response.status(201).entity(builder.toString()).build()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Why does queryParams.size() =1 ...
Even with ?issuekey=TEST-479&summary=newClone&fdfsdf=dsfdsf&sdfsdf=sd
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.