简体   繁体   中英

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?

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

The workaround for me was to use a another project to handle issue when payload exceed linux limit. Parent project would fail with ioexception on git checkout, trigger child project and pass build number, child project query parent via rest api for the payload.

The other workaround is just to use a window node.

Reference: https://serverfault.com/questions/533709/bulk-size-text-parameters-in-jenkins-report-error

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM