My groovy script to change component leads does not work

Hi Guys,

Can someone tell me what I am doing wrong here. Thanks in advance!

import groovy.json.JsonSlurper;
import org.apache.log4j.Logger
import org.apache.log4j.Level
def log = Logger.getLogger("com.acme.CreateSubtask")
def leavingUser = 'robgri' //Mitarbeiter der ersetzt werden soll!
def newUser = 'thogei' //Mitarbeiter der neu zugeteilt werden soll!
def jsonSlurper = new JsonSlurper()
def curl = "/usr/bin/curl -u admin:adminpass"
def output = curl.execute().text
def object = jsonSlurper.parseText(output)
String[] projectKeys = object.key
for (projectKey in projectKeys) {
    curl = "/usr/bin/curl -u admin:adminpass" + projectKey + "/components"
    output = curl.execute().text
    object = jsonSlurper.parseText(output)
    for (component in object) {
        try {
            if ( == leavingUser) {
                def jsonBody = "\"assigneeType\":\"COMPONENT_LEAD\", \"leadUserName\":\"" + newUser + "\", \"project\":\"" + projectKey + "\""
                def process = ["curl", "-u",  "admin:adminpass", "-X", "PUT", "--data", "{" + jsonBody + "}", "-H",  "Content-Type:application/json", "" +]
                output = process.execute().text
        } catch (NullPointerException e) {}

Hi @anon80600472, just a tip: maybe you could describe a little better what your actual problem is. It’s very unlikely that someone will just read your code and tell you what’s wrong. You should at least try to describe what you want to do, what isn’t working, what errors you’re seeing (if any) and what you have already tried so far.