Github webhook triggers jenkins job with too large JSON payload error

I’m working on a continuous integration setup for a project. All code is on a github repo which then gets merged will trigger a webhook to a jenkins server where a specific job is run. From there this job looks at the payload and determines what downstream job to run based on its branch. The rest of the payload is not needed. In the instance where there are a lot of commits in the merge the json payload will be very large, so much that it will break with the following error:

Cloning the remote Git repository
Cloning repository <git_repo>
> git init <http://jenkins_instance/job> # timeout=10
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Could not init <http://jenkins_instance/job>
        ...
Caused by: hudson.plugins.git.GitException: Error performing command: git init <http://jenkins_instance/job>
        ...
Caused by: java.io.IOException: Cannot run program "git" (in directory "<http://jenkins_instance/job>")>: error=7, Argument list too long
        ...
Caused by: java.io.IOException: error=7, Argument list too long
        ...
ERROR: null

MAIN QUESTION:
Is there a way to reduce this payload size? Or a suggestion on how to handle the payload to avoid the error?

  • Adding git submodule that contains another submodule?
  • What is the use of object directory in git?
  • Can I use git 'tag' when I release my project?
  • git: command not found (on OS X 10.5)
  • Git Directory Diff does not work in my submodule
  • Git bash win32exception: Failed to write credentials
  • Setup is similar to this post How to process a github webhook payload in Jenkins?

    Current setup for this job is “Parameterized” and has one parameter “String paramter” for the “payload”. This variable is then saved into a file like so during the main shell execution:

    echo "Current payload is ${payload}"
    if [ -d ./payload.txt ]
    then
        rm payload.txt;
    fi
    touch payload.txt
    echo $payload >> payload.txt
    

  • Can I use Git to apply update patches to customized software?
  • Using git with diffmerge with no prompts and no alias
  • Reclaim space after aborted git add?
  • PMD-Jenkins: how to use it
  • How can I use Git locally?
  • Git marking all new commits as occurring “3 months ago”
  • Git Baby is a git and github fan, let's start git clone.