Given the following example:
def servers = "sftp.host.com:32025|GB,sftp.host.com:32029|ES,sftp.host.com:32030|PT,sftp.host.com:32027|FI," servers.split(',').each { it.split("\\|").each { println("sftp address: ${it[0]} countrycode: ${it[1]}\n") } } The idea was to extract some fields from a delimited list of , then get address|countryCode out from that field to process further, but the only thing i am getting out is the first letter of each field.
sftp address: s countrycode: f sftp address: G countrycode: B ...
Not sure whats going on here?
eachmethod doesn't work in the pipeline due to CPS transformation. Use a for-in loop instead:for(server in servers.split(',')) {…}. Alternatively use@NonCPSannotation, see example.