Hi guys,
im trying to create a issue based in another issue, see my script:
import com.atlassian.jira.component.ComponentAccessor as ca
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.bc.issue.IssueService.CreateValidationResult
import com.atlassian.jira.bc.issue.IssueService.IssueResult
def issueService = ca.getComponent(IssueService.class)
def issueInputParameters = issueService.newIssueInputParameters();
def userManager = ca.getUserManager()
def issueManager = ca.getIssueManager()
def cfManager = ca.getCustomFieldManager()
def user = ca.getJiraAuthenticationContext().getLoggedInUser()
def issue = issueService.getIssue(user, "SD-455636").getIssue()
def nfeed = cfManager.getCustomFieldObject(18402L)
/*Properties*/
def projectId = issue.projectId
def issueTypeId = issue.issueTypeId
def summary = issue.summary
def reporterId = issue.reporterId
def description = issue.description
def environment = issue.environment
def statusId = issue.statusId
def priorityId = issue.priorityId as String
def resolutionId = issue.resolutionId
def securityLevelId = issue.securityLevelId
/*CustomFields Required*/
def cfCategoria = cfManager.getCustomFieldObject(17500L)
def cfDescCategoria = cfManager.getCustomFieldObject(17501L)
def cfServico = cfManager.getCustomFieldObject(17502L)
def cfTelefoneolicitante = cfManager.getCustomFieldObject(15500L)
def cfUsuarioAtendimento = cfManager.getCustomFieldObject(17800L)
def nfeedXML = nfeed.getValue(issue).split('\n')
def users = []
nfeedXML.each{
if(it.endsWith('</value>'))
users.add(it.substring(it.indexOf(' - ') + 3,it.indexOf('</value>')))
}
users.each{
def u = userManager.getUserByKey(it)
}
try{
issueInputParameters.setProjectId(projectId)
.setIssueTypeId(issueTypeId)
.setSummary(summary)
.setReporterId(reporterId)
.setDescription(description)
.setEnvironment(environment)
.setStatusId(statusId)
.setPriorityId(priorityId)
.setResolutionId(resolutionId)
.setSecurityLevelId(securityLevelId)
.addCustomFieldValue(17500L, cfCategoria.getValue(issue).toString())
.addCustomFieldValue(17501L, cfDescCategoria.getValue(issue).toString())
.addCustomFieldValue(17502L, cfServico.getValue(issue).toString())
.addCustomFieldValue(15500L, cfTelefoneolicitante.getValue(issue).toString())
.addCustomFieldValue(17800L, cfUsuarioAtendimento.getValue(issue).toString())
IssueService.CreateValidationResult createValidationResult = issueService.validateCreate(issue.reporter, issueInputParameters);
if (!createValidationResult.isValid()) {
Map<String, String> errorCollection = createValidationResult.getErrorCollection().getErrors();
log.info("ERROR: Validation errors:");
for (String errorKey : errorCollection.keySet()) {
log.info(errorKey);
log.info(errorCollection.get(errorKey));
}
}
def createResult = issueService.create(issue.reporter, createValidationResult)
log.warn createResult.getIssue()
log.warn createResult
}catch(Exception e){
log.warn "Erro ao criar a issue"
log.error(e)
return null
}
This code seems like good, but in atlassian-jira.log dont show me a error and im lost in that problem, anyone can help me what a have to do to resolve the my problem?
Thanks guys.
@JonasGomeshow did you solve the error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.