我的 .travis.yml
中有以下部署部分
deploy:
provider: script
script: bash scripts/deploy.sh
skip_cleanup: true
on:
all_branches: true
问题是 bash script/deploy.sh
可能需要 7 到 10 分钟之间的时间,这意味着这有时会超过 travis 默认情况下的 10 分钟超时。但不用担心 - travis 提供 travis_wait 。这是我更新的 .travis.yml
。
deploy:
provider: script
script: travis_wait 30 bash scripts/deploy.sh
skip_cleanup: true
on:
all_branches: true
问题是,此操作失败,脚本失败,状态为 127
。
是否可以在脚本部署中使用travis_wait
?
最佳答案
我通过将部署命令(npm run deploy)包装在一个简单的脚本中来解决这个问题:
#!/bin/bash
npm run deploy &
# Output to the screen every 9 minutes to prevent a travis timeout
export PID=$!
while [[ `ps -p $PID | tail -n +2` ]]; do
echo 'Deploying'
sleep 540
done
关于travis-ci - travis脚本部署超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39288834/