Re: [gitorious] Gitorious Plugin for Jenkins

408 views
Skip to first unread message

Marius Mårnes Mathiesen

unread,
Oct 16, 2012, 4:57:10 AM10/16/12
to gito...@googlegroups.com
On Mon, Oct 15, 2012 at 11:07 PM, Scott Moyer <relo...@gmail.com> wrote:
I added functionality to the Jenkins git-plugin to support Gitorious webhooks and they've rolled it off into it's own plugin.

Scott,
Great work!
 

You can add the git-plugin and gitorious-plugin to jenkins.  Create a webhook in Gitorious that will post to http://yourjenkins/gitorious/notifyCommit (or  http://yourjenkins/jenkins/gitorious/notifyCommit in some cases).

The gitorious plugin will parse the payload and attempt to kick off a jenkins build.  

There was a post a while back about someone trying to make this work.  The webhook POST in Gitorious was striping off any hard coded query parameters, so it wouldn't work with the git-plugin out of the box. 

Is this still a problem?

Cheers,
- Marius

Scott Moyer

unread,
Oct 16, 2012, 11:27:29 AM10/16/12
to gito...@googlegroups.com
It looks like the hard coded query parameter issue is a Ruby 1.8 problem.  The post_form code doesn't take hard coded query parameters into account.

# File net/http.rb, line 400
def HTTP.post_form(url, params)
  req = Post.new(url.path)
  req.form_data = params
  req.basic_auth url.user, url.password if url.user
  new(url.host, url.port).start {|http|
    http.request(req)
  }
end

It looks like Ruby 1.9 passes along the query parameters in a post, but I haven't tested it.  

# File net/http.rb, line 478
def HTTP.post_form(url, params)
  req = Post.new(url.request_uri)
  req.form_data = params
  req.basic_auth url.user, url.password if url.user
  new(url.hostname, url.port).start {|http|
    http.request(req)
  }
end

#
# == Description
#
# Returns the full path for an HTTP request, as required by Net::HTTP::Get.
#
# If the URI contains a query, the full path is URI#path + '?' + URI#query.
# Otherwise, the path is simply URI#path.
#
def request_uri
  r = path_query
  if r[0] != ?/
    r = '/' + r
  end

  r
end

I don't have control over the server environment that we use to run Gitorious.  The gitorious-plugin for Jenkins was the easiest way for me to get this working, and it was fun to dig around in some open source projects ;) 

Thanks for a great product,

Scott

Reply all
Reply to author
Forward
0 new messages