Skip to content

Jenkins integration fails with undefined method ‘post’

Zendesk ticket: https://gitlab.zendesk.com/agent/tickets/14149
GitLab: 8.3.0

Observed Behavior

After integrating Jenkins the Test Settings button will end by publishing a flash message with a content similar to:

  We tried to send a request to the provided URL but an error occurred: undefined 
  method ‘post’ for #<JenkinsService:0x000000006ecca88>

Expected Behavior

If the configuration is correct the Test Settings button should publish a message like:

  We sent a request to the provided URL

Error Reproduction

  1. Follow the Jenkins integration steps from http://doc.gitlab.com/ee/integration/jenkins.html
  2. When you get to activating the Jenkins CI service at the Project Settings area press the Test Settings button.
  3. The error appears as a flash message.

Next Steps

@patricio suggested changing self.postto self.class.postwhich I can confirm solved this issue.

 # jenkins_service.rb
 def execute(data)
    self.post(
      hook_url,
      body: data.to_json,
      headers: {
        'Content-Type' => 'application/json',
        'Authorization' => "Basic #{auth}"
      }
    )
  end

/cc @JobV How should we proceed? Should I work on a MR or should we leave it to a developer for further testing?

Edited by Service Account - security-triage