retrieving post data from web hook in jenkins

I am using gitlab and I want to fire a system hook whenever a project is created. I have added the hook with the following jenkins api call(I am using a jenkins plugin that is why the api looks different).

http://myip:8081/buildByToken/buildWithParameters?job=testHook&token=hook

this is starting the jenkins job but I am unable to get the post data sent by the hook in my jenkins job.

the following is an example of what gitlab sends as post data with this hook.

{
          "created_at": "2012-07-21T07:30:54Z",
          "event_name": "project_create",
                "name": "StoreCloud",
         "owner_email": "johnsmith@gmail.com",
          "owner_name": "John Smith",
                "path": "stormcloud",
          "path_with_namespace": "jsmith/stormcloud",
          "project_id": 74,
           "project_visibility": "private",
}

is there a way to retrieve post data in jenkins that is sent with the webook?

  • Class cast exceptions with ant/jenkins generated EAR on WebSphere 6.1
  • How to mark a build unstable in Jenkins when running shell scripts
  • Jenkins + populate changes from last build
  • Check if property exists Groovy
  • What is the difference between Hudson and CruiseControl for Java projects?
  • How to set assembly version to Jenkins build number?
  • start daemon on remote server via Jenkins SSH shell script exits mysteriously
  • Building tags using Continuous Integration
  • One Solution collect form web for “retrieving post data from web hook in jenkins”

    There is a plugin specific for Jenkins and Gitlab integration.

    https://github.com/elvanja/jenkins-gitlab-hook-plugin#build-now-hook

    By using http://your-jenkins-server.com/gitlab/build_now, you can have access to all payload variables, like the examples in documentation. Your build needs to be parameterized, and all variables you want to have access need to be declared. Then, you will have a env variable available, like ${USER_NAME}

    However, if you want to use /gitlab/notify_commit, which has a lot of more cool possibilities, payload data will not work, because of the gap between the trigger and the build (i am talking about the poll process).

    I believe that your /buildByToken/buildWithParameters, since its a build_now like, will have the payload. Using GitLabHookPlugin, you will have the parameters for sure.

    Marco

    Git Baby is a git and github fan, let's start git clone.