如何解决 Travis CI 的 4MB 输出限制? [英] how to work around Travis CIs 4MB output limit?

查看:26
本文介绍了如何解决 Travis CI 的 4MB 输出限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Travis CI 构建,它产生超过 4MB 的输出,超出了 Travis CI 的限制.

I have a Travis CI build that produces more than 4MB of output which exceeds Travis CIs limit.

我曾尝试将输出发送到/dev/null,但如果 10 分钟没有看到输出,Travis 也会失败

I have tried sending output to /dev/null, but Travis also fails if no output is seen for 10 minutes

如何解决这些限制?

推荐答案

以下脚本发送一些虚拟输出以保持构建活动,但也将构建输出记录到文件中,如果构建返回错误:

The following script sends some dummy output to keep the build alive but also records the build output to a file and displays a tail of the output if the build returns an error:

#!/bin/bash
# Abort on Error
set -e

export PING_SLEEP=30s
export WORKDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export BUILD_OUTPUT=$WORKDIR/build.out

touch $BUILD_OUTPUT

dump_output() {
   echo Tailing the last 500 lines of output:
   tail -500 $BUILD_OUTPUT  
}
error_handler() {
  echo ERROR: An error was encountered with the build.
  dump_output
  exit 1
}
# If an error occurs, run our error handler to output a tail of the build
trap 'error_handler' ERR

# Set up a repeating loop to send some output to Travis.

bash -c "while true; do echo \$(date) - building ...; sleep $PING_SLEEP; done" &
PING_LOOP_PID=$!

# My build is using maven, but you could build anything with this, E.g.
# your_build_command_1 >> $BUILD_OUTPUT 2>&1
# your_build_command_2 >> $BUILD_OUTPUT 2>&1
mvn clean install >> $BUILD_OUTPUT 2>&1

# The build finished without returning an error so dump a tail of the output
dump_output

# nicely terminate the ping output loop
kill $PING_LOOP_PID

这篇关于如何解决 Travis CI 的 4MB 输出限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆