Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-36486

httpRequest executes from Jenkins Master node

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • http-request-plugin
    • 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>)
      

            janario Janario Oliveira
            jzila John Zila
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: