Hi All,
I got the result after running the groovy script in script runner. But I need to catch id in a variable.
How is it possible to catch the value of Id in a variable?
import groovyx.net.http.ContentType
import groovyx.net.http.*
import static groovyx.net.http.Method.*
import groovy.json.JsonOutput
import net.sf.json.groovy.JsonSlurper
import groovy.json.JsonSlurper
//Authorization
def authString = "user:passwd".bytes.encodeBase64().toString()
def bodyJson = JsonOutput.toJson([name: "Testing Automate deployment", planKey:["key":"TP-MS"], description:"Testing REST API"])
def slurper = new groovy.json.JsonSlurper()
def http = new HTTPBuilder( 'https://bamboo-abc.com/rest/api/latest/deploy/project' )
http.request(PUT) {
headers."Authorization" = "Basic ${authString}"
body = bodyJson
requestContentType = ContentType.JSON
//response.success = { resp ->
//log.warn "Creating new delpyment project request Success! ${resp.status}"
response.failure = { resp, reader ->
log.warn "Creating new delpyment project request Success! ${resp.status}"
}
response.failure = { resp ->
log.warn "Creating new delpyment project request failed with status ${resp.status}"
log.warn resp.statusLine
}
}
[id:33587298, oid:8rpzfqhc4p5u, key:[key:33587298], name:Testing Automate deployment, planKey:[key:TP-MS], description:Testing REST API, environments:[], operations:[canView:true, canEdit:true, canDelete:true, allowedToExecute:false, canExecute:false, allowedToCreateVersion:true, allowedToSetVersionStatus:false], repositorySpecsManaged:false]