Reading HTTP request body from triggered parameterized job

2,475 views
Skip to first unread message

Alex Kira

unread,
Sep 18, 2013, 5:46:15 PM9/18/13
to jenkins...@googlegroups.com
Hi, 

Is there a way to read the request body from a triggered job?  I am trying to integrate with another service that posts the request parameters as JSON in the raw body.  

This is a curl request that generates a similar request:

curl -X POST -H "Content-Type: application/json" -d '{"commits":"xyz","payload":"xyz"}' http://jenkins-url.com/job/Test/buildWithParameters

Is there a way to access the posted JSON in my build scripts?  (Note that I cannot change the format of the request or how the JSON is passed).

Thanks, 

Alex

JonathanRRogers

unread,
Sep 19, 2013, 2:35:09 PM9/19/13
to jenkins...@googlegroups.com


This sounds like it would require significant Jenkins extension since you want to teach it another API. I would probably be more inclined to write a proxy service which translates from the API of your other service to that of Jenkins. I'm not sure what you're used to, but I've done something similar with a page or two of Python.

Alex Kira

unread,
Sep 19, 2013, 9:47:39 PM9/19/13
to jenkins...@googlegroups.com
Yeah I figured it would be the case, but wanted to check just in case.  I ended up writing a proxy that will translate Gitlab webhook requests and send the JSON as a "payload" parameter to another url specified by a url param (which would be Jenkins job trigger).  It will also send a few other parameters as that can be used as Jenkins parameters without having to parse the JSON. 

Code is here in case anyone else runs into this issue:


Thanks, 

Alex Kira

Owen B. Mehegan

unread,
Sep 22, 2013, 5:11:13 PM9/22/13
to jenkins...@googlegroups.com
Did you try the gitlab Jenkins plugin?

Alex Kira

unread,
Sep 23, 2013, 10:21:48 PM9/23/13
to jenkins...@googlegroups.com
I saw it, but wasn't sure if it was configurable enough for my use case since it just kicks off all associated builds.  I will take a look at it again though.

Thanks..


On Sun, Sep 22, 2013 at 2:11 PM, Owen B. Mehegan <ow...@nerdnetworks.org> wrote:
Did you try the gitlab Jenkins plugin?

--
You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/mkM7UCkkOnk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Owen B. Mehegan

unread,
Sep 24, 2013, 1:22:15 PM9/24/13
to jenkins...@googlegroups.com
Yeah, it has that attribute, and it also kicks off a build no matter what branch your commit is for. Previously I used a custom git post-receive hook to trigger builds only if a commit was for the master branch. I might end up creating a proxy like what you used to do more filtering.
Reply all
Reply to author
Forward
0 new messages