[英]Jenkins pipeline - shell command killed zipping a large directory
I have Jenkins Groovy Pipeline where I am zipping a large directory (around 200 MB). 我有Jenkins Groovy Pipeline,我正在压缩一个大目录(大约200 MB)。 However, shell command is getting killed with errors like:
但是,shell命令会因以下错误而被杀死:
./package-code-to-s3.sh: line 18: 20091 Killed
OR 要么
line x: 28026 Killed
OR 要么
./package-code-to-s3.sh: line 13: 7162 Killed
Following is my Pipeline code for the stage: 以下是我的舞台管道代码:
stage ("Package") {
sh """#!/bin/bash
set -e
echo "Packging"
chmod +x package-code-to-s3.sh
./package-code-to-s3.sh ${S3_BUCKET}
aws s3 cp packaged.yaml s3://builds/Templates/${env.JOB_NAME}/${env.BUILD_NUMBER}-packaged.yaml
"""
}
and following is code for package-code-to-s3.sh : 以下是package-code-to-s3.sh的代码:
#!/bin/bash
set -e
S3_BUCKET_NAME=$1
FILE_NAME_UUID=`python -c 'import uuid; print str(uuid.uuid1())'`
echo "UUID: $FILE_NAME_UUID"
ZIP="`pwd`/$FILE_NAME_UUID"
echo "ZIP FILE : $ZIP"
cd .aws-sam/build/LambdaHandlers/
echo "Executing zip -fz -q -r $ZIP"
nohup zip -fz -q -r $ZIP . > log.output 2>&1 &
ls -las
cd ../../../
ls -las
ls -las
mv "$FILE_NAME_UUID.zip" $FILE_NAME_UUID
CODE_URI="s3://$S3_BUCKET_NAME/$FILE_NAME_UUID"
aws s3 cp $FILE_NAME_UUID $CODE_URI
If I run the same commands from the command line, it works perfectly fine. 如果我从命令行运行相同的命令,它完全正常。
To me, this seems to be an issue with either buffer or heap memory OR issue with running zip in the pipeline. 对我来说,这似乎是缓冲区或堆内存的问题或在管道中运行zip的问题。
My Jenkins instance has just one job running (this one) and Jenkins machine has enough memory, so, RAM shouldn't be an issue. 我的Jenkins实例只运行了一个作业(这个)并且Jenkins机器有足够的内存,因此,RAM应该不是问题。
Any help/suggestion is appreciated. 任何帮助/建议表示赞赏。
Since there was nothing helpful in logs, and it looked like a memory issue to me. 由于日志中没有任何帮助,对我来说这看起来像是一个内存问题。 I copied the code of
package-code-to-s3.sh
to my Jenkinsfile package stage, and, restarted my Jenkins instance. 我将
package-code-to-s3.sh
的代码复制到我的Jenkinsfile包阶段,并重新启动了我的Jenkins实例。 Strange it might sound, the issue was resolved for me by doing this. 听起来很奇怪,这个问题通过这个解决了。
Thanks 谢谢
Since there was nothing helpful in logs, and it looked like a memory issue to me. 由于日志中没有任何帮助,对我来说这看起来像是一个内存问题。 I tried the following:
我尝试了以下方法:
package stage
package stage
Strange it might sound, the issue was resolved for me by doing this. 听起来很奇怪,这个问题通过这个解决了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.