title: Jenkins post build task unable to run script
body: <p>I have simple bash script <code>script.sh</code> in my <code>/home/ubuntu/jenkins/workspace</code> folder. This bash script runs - </p>
  
  <pre><code>cd /home/ubuntu/tools; /home/ubuntu/.rbenv/shims/ruby script.rb
  </code></pre>
  
  <p>In this ruby script I have several environment variable for API keys and it looks to be where the script is having issues with. Here is the error message I'm receiving from jenkins when the post build task runs - </p>
  
  <pre><code>Performing Post build task...
  Match found for : : True
  Logical operation result is TRUE
  Running script  : /home/ubuntu/jenkins/workspace/script.sh
  [Ansible-Deploy] $ /bin/sh -xe /tmp/jenkins3728886043127394122.sh
  + /home/ubuntu/jenkins/workspace/script.sh
  /home/ubuntu/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/graphql-1.7.13/lib/graphql/schema/loader.rb:16:in `fetch': key not found: "data" (KeyError)
    from /home/ubuntu/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/graphql-1.7.13/lib/graphql/schema/loader.rb:16:in `load'
    from /home/ubuntu/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/graphql-client-0.12.2/lib/graphql/client.rb:52:in `load_schema'
    from /home/ubuntu/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/graphql-client-0.12.2/lib/graphql/client.rb:60:in `load_schema'
    from /home/ubuntu/tools/script.rb:274:in `&lt;module:Github&gt;'
    from /home/ubuntu/tools/script.rb:264:in `&lt;main&gt;'
  POST BUILD TASK : FAILURE
  END OF POST BUILD TASK : 0
  </code></pre>
  
  <p>And in that script.rb file around line 264 - </p>
  
  <pre><code>GITHUB_ACCESS_TOKEN = ENV['GITHUB_ACCESS_TOKEN']
  
  ...
  
  module Github
    HttpAdapter ||= GraphQL::Client::HTTP.new(URL) do
      def headers(context)
        {
          "Authorization" =&gt; "Bearer #{GITHUB_ACCESS_TOKEN}",
          "User-Agent" =&gt; 'Ruby'
        }
      end
    end
  
    Schema ||= GraphQL::Client.load_schema(HttpAdapter)
    Client ||= GraphQL::Client.new(schema: Schema, execute: HttpAdapter)
  end
  </code></pre>
  
  <p>Important to note that either running the bash script or ruby script while ssh'd in works fine, its only fails when run from the jenkins post build task.</p>