yml_1:
server
port: 1023
yml_2:
server
port: 4001
I use readYaml
in Jenkins to read the YAML file:
void checkService(waitTime) {
def conf = readYaml file: "./${CURRENT_STAGE}/src/main/resources/${CONF_NAME}"
String port = conf.server.port.toString()
timeout(waitTime) {
waitUntil {
script {
def r = sh script: "wget -q http://${HOST_NAME}:${port}/info -O /dev/null", returnStatus: true
return (r == 0)
}
}
}
}
It works fine in first yml, the url returns http://hostname:1023/info, but it returns array if calls checkService() again for second yml file: http://hostname:[4001]/info
Where is the problem?
I use this solved
def conf = readYaml file: "${CONF_NAME}"
String port = ""
if ( conf.server.port instanceof Integer ) {
port = conf.server.port
}
if ( conf.server.port instanceof ArrayList ) {
port = conf.server.port[0]
}