-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
Jenkins 2.10, HTTP Request Plugin 1.8.11
We use the EC2 Metadata API to retrieve the local host IP. Creating a new URL() object and getting the text from the result showed that it was running on the queueing machine. Fair enough, understandable for the groovy script to initially get executed on that one first.
However, I then installed the httpRequest plugin, hoping that it would solve that problem. Nope.
sh "curl -s http://169.254.169.254/latest/meta-data/public-ipv4 > public.txt" sh "curl -s http://169.254.169.254/latest/meta-data/local-ipv4 > private.txt" def nodePublicIP = readFile('public.txt') def nodePrivateIP = readFile('private.txt') sh "rm public.txt" sh "rm private.txt" def httpRequestPublicIP = httpRequest("http://169.254.169.254/latest/meta-data/public-ipv4").content def httpRequestPrivateIP = httpRequest("http://169.254.169.254/latest/meta-data/local-ipv4").content println "Running on host $nodePublicIP ($nodePrivateIP)" println "httpRequest says host $httpRequestPublicIP ($httpRequestPrivateIP)"
Output:
[Pipeline] echo Running on host <node public IP> (<node private IP>) [Pipeline] echo httpRequest says host <Jenkins master public IP> (<Jenkins master private IP>)