//Using the fixed values in below for demonstration only. Assign the data from variables / properties as needed

//Assign the response dynamically from previous step
def jsonString = '''[
    {
        "SourceId": "bc3cef1e-a9f1-46df-a4f0-c1131357ea57",
        "SourceCode": "ABC",
        "CodeTier": "123",
        "SourceDescription": "ABC Desc"
    },
    {
        "SourceId": "b4035134-ca33-4b33-b3c7-06ea880f1f28",
        "SourceCode": "DEF",
        "CodeTier": "456",
        "SourceDescription": "DEF Descr"
    },
    {
        "SourceId": "9666bd19-1916-4052-9044-06b0e38e9175",
        "SourceCode": "GHI",
        "SourceDescription": "GHI Descr"
    }
]'''


def json = new groovy.json.JsonSlurper().parseText(jsonString)

def getSourceIdBySourceCode = { code -> json.find {it?.SourceCode == code}?.SourceId }

println "SourceId for ABC is : ${getSourceIdBySourceCode('ABC')}"


//Test all the source id and codes

def expectedCodeIdMap = [ ABC: 'bc3cef1e-a9f1-46df-a4f0-c1131357ea57', DEF: 'b4035134-ca33-4b33-b3c7-06ea880f1f28', GHI: '9666bd19-1916-4052-9044-06b0e38e9175']
expectedCodeIdMap.each { code, id ->
	println "verifying $code with expected $id"
	assert id == getSourceIdBySourceCode(code)
}

println getSourceIdBySourceCode('123')