Github webhook触发了jenkins作业,其中包含过大的JSON有效负载错误

问题描述 投票:2回答:1

我正在为项目进行持续集成设置。所有代码都在github repo上,然后合并将触发webhook到jenkins服务器,在该服务器上运行特定的作业。从那里,该作业查看有效负载并根据其分支确定要运行的下游作业。不需要其余的有效负载。在合并中有大量提交的情况下,json有效负载将非常大,以至于它会因以下错误而中断:

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

主要问题:有没有办法减少这个有效载荷的大小?或者建议如何处理有效负载以避免错误?

设置类似于这篇文章How to process a github webhook payload in Jenkins?

此作业的当前设置为“参数化”,并且“有效负载”具有一个参数“字符串参数”。然后在主shell执行期间将此变量保存到文件中:

echo "Current payload is ${payload}"
if [ -d ./payload.txt ]
then
    rm payload.txt;
fi
touch payload.txt
echo $payload >> payload.txt
json git jenkins webhooks
1个回答
0
投票

对我来说,解决方法是在有效负载超过linux限制时使用另一个项目来处理问题。父项目将在git checkout上触发ioexception,触发子项目并传递内部版本号,子项目查询父项通过rest api获取有效负载。

另一种解决方法是使用窗口节点。

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

© www.soinside.com 2019 - 2024. All rights reserved.