Hi Community,
I've been struggling this problem for 3 days.
When I put the same code in console ScriptRunner the code it works ok but when I move it I have more problems, but I have 2 problems.
The method startsWith() -->but I don't work whit it
ERROR - Cannot invoke method startsWith() on null object
and I have ote rerror when I change
Here is my source code :
////////////////////////nuevo codigo 04/10/2018
def transitionId = '61' //transicion (Finalizar desarrollo) DEMANDA a [Entregada]
def issueKey = issue.key
/*------------------EDU--------------------*/
def result = get('/rest/api/2/issue/' + issueKey)
.header('Content-Type', 'application/json')
.asObject(Map)
if (result.status >= 200 && result.status < 300){
logger.info('ok return')
} else {
return "Failed to find issue: Status: ${result.status} ${result.body}"
}
////////////////////////nuevo codigo 01/10/2018
/*------------------EDU--------------------*/
def link = result.body.fields.issuelinks //Busco todos los issuelinks de la DEM para saber el tipo de issue que cuelga de él
def num_issue = result.body.fields.issuelinks.size() //numero de tareas que cuelgan de la DEM
logger.info('links: '+num_issue)
for(def x = 0; x < num_issue; x++){
logger.info('entra en el for: '+x)
logger.info(link[x].inwardIssue)
preguntamos por los primeros estados del WF antes de hacer un movimiento
if (link[x]?.inwardIssue?.fields.issuetype.name == 'Historia' ||
link[x]?.inwardIssue?.fields.issuetype.id == '10300'){
if (link[x]?.inwardIssue?.fields.status.name == 'ENTREGADA (PTE. ACEPTACIÓN)' ){}
else return false
}
}
def resultTrans = post('/rest/api/2/issue/'+issueKey+'/transitions')
.header('accept', 'application/json')
.header('Content-Type', 'application/json')
.body('{\"transition\":{\"id\": \"'+transitionId+'\"}}')
.asJson()
if (resultTrans.status >= 200 && resultTrans.status < 300){
logger.info('transitionId='+transitionId)
return 'success y transitionId = ' + transitionId
} else {
return "Failed to find issue: Status: ${resultTrans.status} ${resultTrans.body}"
}
/*------------------EDU--------------------*/