I have issues extracting stdout to get only the result, last(second line).
i have jenkins pipeline using groovy script which executes the following:
stdout = bat([
script: 'C:/folder/generate.exe --environment %ENVIRONMENT% --optionalproperties %OPTIONALPROPS%',
if i pass echo stdout, to capture what this command generated, i get stdout as -
C:\folder2\folder2>C:/folder1/generate.exe --environment PROD --optionalproperties something
So my result is in new line, 12345678. I need to capture only this.
I used before to do this with:
result = stdout.readLines().drop(1).split(" ")
and i was getting just the 12345678. But it stopped working somehow.
I managed to find a workaround with this:
result = stdout.reverse().take(8).reverse()
which takes last 8 numbers and extracts them. But it's not good solution as i might have more or less amount of numbers generated, so i need a proper way to extract it.
Any advise guys what i could try else as i dont get why readLines() fails to get me any result, though the batch command didnt change?