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

  • Concourse: Trigger a job with a HTTP request
  • What is the most notable difference between Jenkins and Hudson from an user perpective?
  • Hudson or Teamcity for continuous integration?
  • git workflows: how to integrate and test feature branches without continuous delivery?
  • How to run jenkins as a different user
  • What is the difference between Hudson and CruiseControl for Java projects?
  • 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 Publish over ssh authentification failed with private key
  • Jenkins - make agents wait for other agent to finish
  • transform opencover xml output to ncover xml
  • Continuous Integration Advice?
  • In Gerrit, how can I prevent a patch set from being submitted that is not completely up-to-date?
  • extract pom version in a jenkins pipeline
  • 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.