У меня есть следующий код.Он получает имена файлов, доступные локально в рабочей области Jenkins, читает файлы и пытается отправить их содержимое в конечную точку.
Для service-configuration.json
это работает.Тем не менее, для остальных файлов происходит сбой с StackOverflowError ...
// Update Service configuration.
serviceJson = readJSON file: "service-configuration.json"
response = httpRequest validResponseCodes: "100:504", acceptType: "APPLICATION_JSON", contentType: "APPLICATION_JSON", customHeaders: [[name: 'Authorization', value: iamToken]], httpMode: "PUT", requestBody: new JsonBuilder(serviceJson).toPrettyString(), url: GlobalCatalog.service
if (response.status != 200) {
println "Failure: ${response.status} ${response.content}"
currentBuild.result = 'FAILURE'
error "Failed uploading Global Catalog entry."
}
// Update Plans and their Deployments configurations.
GlobalCatalog.plans.each { plan ->
planJson = readJSON file: "${plan.planName}-plan-configuration.json"
response = httpRequest validResponseCodes: "100:504", acceptType: "APPLICATION_JSON", contentType: "APPLICATION_JSON", customHeaders: [[name: 'Authorization', value: iamToken]], httpMode: "PUT", requestBody: new JsonBuilder(planJson).toPrettyString(), url: plan.url
if (response.status != 200) {
println "Failure: ${response.status} ${response.content}"
currentBuild.result = 'FAILURE'
error "Failed uploading Global Catalog entry."
} else {
plan.deployments.each { deployment ->
deploymentJson = readJSON file: "${plan.planName}-${deployment.region}-deployment-configuration.json"
response = httpRequest validResponseCodes: "100:504", acceptType: "APPLICATION_JSON", contentType: "APPLICATION_JSON", customHeaders: [[name: 'Authorization', value: iamToken]], httpMode: "PUT", requestBody: new JsonBuilder(deploymentJson).toPrettyString(), url: deployment.url
if (response.status != 200) {
println "Failure: ${response.status} ${response.content}"
currentBuild.result = 'FAILURE'
error "Failed uploading Global Catalog entry."
}
}
}
}
StackOverflowError:
java.lang.StackOverflowError
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
at groovy.json.JsonOutput.writeObject(JsonOutput.java:321)
at groovy.json.JsonOutput.writeMap(JsonOutput.java:458)
Редактировать: если я использую toString()
вместо этого, он работает - нокодировка различных языковых строк в файле не сохраняется ...