在我们的 jenkins 构建配置中,我们将以下 shell 命令(执行 shell)作为构建过程的最后一步。
echo "$USER"
echo "Script executed from: ${PWD}"
git submodule update --init --recursive
if [ -f composer.json ]; then
/usr/local/bin/composer install
fi
sed -i 's/phpunit --bootstrap/\/usr\/local\/bin\/phpunit \-\-bootstrap/g' runtest
./runtest --config unittest/configure.conf --coverage /var/lib/jenkins/workspace/coverage/
一切曾经运行正常,直到我们的硬盘满了,jenkins 停止构建。在我们清理硬盘并再次尝试通过 jenkins 构建后,最后一步(执行 shell)构建失败,并出现以下错误:
[project] $ /bin/sh -xe /tmp/hudson815776538860444797.sh
+ echo jenkins
jenkins
+ echo 'Script executed from: /var/lib/jenkins/workspace/project'
Script executed from: /var/lib/jenkins/workspace/project
+ git submodule update --init --recursive
error: git-submodule died of signal 9
Build step 'Execute shell' marked build as failure
我们尝试以 root 身份运行 shell 命令,一切如预期。但是,一旦我们以 jenkins 用户身份运行它,该进程就会在几秒钟内被终止。
[root@localhost project]# su -c "/bin/bash -x /tmp/hudson5288327457846724302.sh" -s /bin/sh jenkins
+ echo jenkins
jenkins
+ echo 'Script executed from: /var/lib/jenkins/workspace/project'
Script executed from: /var/lib/jenkins/workspace/project
+ '[' -f composer.json ']'
+ /usr/local/bin/composer install
Killed
我检查了系统日志,/var/log/messages
但没有找到任何线索。是什么原因导致了这个问题?我们如何解决这个问题?
答案1
您的机器的状态如何,特别是内存:
free -m
这可能是 OOM 杀手。你会看到日志。尝试
grep -i “killed process” /var/log/messages