I'm using a groovy script to calculate my build duration and publish a metric to Hosted Graphite, from the command line the following curl will result with the intend effect:
echo {someMetricHere} | nc carbon.hostedgraphite.com 2003
However in my groovy script the last step having generated a metric is to run the following:
"echo "+ metric +" | nc carbon.hostedgraphite.com 2003".execute()
Its returning:
Caught: java.io.IOException: Cannot run program "|": error=20, Not a directory java.io.IOException: Cannot run program "|": error=20, Not a directory at hudson8814765985646265134.run(hudson8814765985646265134.groovy:27) Caused by: java.io.IOException: error=20, Not a directory ... 1 more
I assume the command doesn't understand the "|" part of the command, any suggestions how I can fix this script to run the intended bash? I thought it might be possible to create a .sh file in the workspace but am not sure how.
Pastebin for those wanting to see full script: https://pastebin.com/izaXVucF
Cheers :)