如何避免 Travis CI timeout 中斷任務?

CI/CD

我們家是用 Travis CI 的 Core – 5 Concurrent Builds 方案,一直以來我都沒什麼使用上的問題,直到我跑了一個執行很久的 task,才發現它 10 分鐘內沒印出任何 log 會自動幫我中斷任務。

原因

Travis CI Documentation
Customizing the Build

會被中斷的狀況:

  • When a job produces no log output for 10 minutes.
  • When a job on a public repository takes longer than 50 minutes.
  • When a job on a private repository takes longer than 120 minutes.

會發生上述原因可能是:

  • Waiting for keyboard input or other kind of human interaction
  • Concurrency issues (deadlocks, livelocks and so on)
  • Installation of native extensions that take very long time to compile

解決方法

別人的 workaround,在設定檔跑迴圈印 log 避免中斷:

ballerina/.travis.yml at master · SupunS/ballerina
Ballerina is a new programming language for integration built on a sequence diagram metaphor. - ballerina/.travis.yml at...

官方其實有提供 travis_wait 來等待耗時任務,使用範例如下:

install: travis_wait 30 mvn install

以上述範例來說,30 就是要等待的時間,單位為分鐘。

但我使用 travis_wait 後,發現 log 就不再出現了,可能是 process 被丟到背景執行,導致想看的 log 沒辦法當下印出,這些 log 會在最終執行結束才一口氣顯示;其實滿困擾的,因為無法得知當下在做什麼。

官方文件可參考:

Travis CI Documentation
Common Build Problems

最終還是選擇 workaround 來當作本次的解決方案,因為它更貼近現實需求。

留言列表

Copied title and URL