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

  • TeamCity - keeping Git submodule up to date?
  • Jenkins transferring 0 files using publish over SSH plugin
  • Skip a submodule during a maven build
  • Promote all builds to master on Jenkins
  • How to get runtime access to version number of a running Clojure application?
  • Email notification for subversion polling failures in Jenkins
  • 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?

  • Jenkins: Gerrit & Git plugin - missing refspec field?
  • aliasing jenkins artifact URLs
  • Github-Jenkins Trigger issue with slave
  • Cancel queued builds and aborting executing builds using Groovy for Jenkins
  • How to list the slowest JUnit tests in a multi-module Maven build
  • Adding a png image and table html while sending email in Jenkins
  • 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.