简体   繁体   English

Jenkins管道 - shell命令杀死了一个大目录

[英]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. 任何帮助/建议表示赞赏。

EDIT 编辑

Issue Resolved 问题解决了

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 谢谢

Issue Resolved 问题解决了

Since there was nothing helpful in logs, and it looked like a memory issue to me. 由于日志中没有任何帮助,对我来说这看起来像是一个内存问题。 I tried the following: 我尝试了以下方法:

  • I copied the code of package-code-to-s3.sh to my Jenkinsfile package stage 我将package-code-to-s3.sh的代码复制到我的Jenkinsfile package stage
  • Added Workspace cleanup before checkout (just to ensure a clean workspace) 在结账前添加了工作区清理(只是为了确保工作区干净)
  • Restarted my Jenkins instance (machine). 重启我的Jenkins实例(机器)。

Strange it might sound, the issue was resolved for me by doing this. 听起来很奇怪,这个问题通过这个解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jenkins 管道中的 Shell 脚本 cd 命令给出错误“没有这样的文件或目录” - Shell script cd command in Jenkins pipeline is giving error "no such file or directory" 无法在 Jenkins 管道中运行多行 shell 命令 - Not able to run multiline shell command in Jenkins pipeline Shell 命令无法从 jenkins 管道运行 - Shell command not working from jenkins pipeline 在 YML 管道中使用 shell 脚本更改 Jenkins 中的目录 - Change directory in Jenkins using shell script in YML pipeline 在 Jenkinsfile 的 shell 命令中为 Jenkins 管道使用参数 - Using parameters within a shell command in Jenkinsfile for Jenkins pipeline 如果相同的 shell 命令位于 Jenkins 管道的不同阶段,则其行为会有所不同 - The same shell command behaves differently if it is located in different stages of Jenkins pipeline zip 命令未在 shell 脚本中压缩文件 - zip command not zipping files in shell script 在 jenkins 中运行命令 shell - Run a command shell in jenkins Jenkins 管道:使用在 shell 1 中创建的变量,在 shell 2 中 - Jenkins pipeline : using variable created in shell 1, in shell 2 Linux 命令在管道的 shell 脚本中删除特定目录以外的目录失败 - Linux command to delete directory except specific directory fail in shell script of pipeline
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM