2017-08-08 140 views
0

我有以下的特拉維斯CI YML文件片段:特拉維斯CI直列bash腳本

script: 
    - if [ $TRAVIS_BRANCH == "master" ]; then 
     sbt clean coverage test coverageReport docker:publishLocal; 
    fi 
    - if [ $TRAVIS_BRANCH == "/^develop-.*$/" ]; then 
     sbt clean coverage test coverageReport; 
    fi 

它有點工作,但我不明白的是它產生的日誌。這是有點誤導。以下是來自構建服務器的日誌:

[success] Total time: 22 s, completed Aug 8, 2017 5:29:28 PM 

The command "if [ $TRAVIS_BRANCH == "master" ]; then sbt clean coverage test coverageReport docker:publishLocal; fi" exited with 0. 
0.00s 

$ if [ $TRAVIS_BRANCH == "/^develop-.*$/" ]; then sbt clean coverage test coverageReport; fi 

The command "if [ $TRAVIS_BRANCH == "/^develop-.*$/" ]; then sbt clean coverage test coverageReport; fi" exited with 0. 

如何運行任何不能退出的代碼0?我寧可期望它只是說,它會跳過該腳本。你們有什麼感想?

回答

1
"if [ $TRAVIS_BRANCH == "master" ]; then sbt clean coverage test coverageReport docker:publishLocal; fi" 

完整是travis用作該步驟的命令。即使if語句的'true'分支沒有執行,travis仍然成功執行了一個命令,因此exit 0。如果你想跳過的配置信息,你就必須給他們自己

- if [ $TRAVIS_BRANCH == "master" ]; then 
     sbt clean coverage test coverageReport docker:publishLocal; 
    else 
     echo "Skipped" 
    fi 

添加另外,您的第二次檢查是在也許不是做你想要什麼。使用=~運算符啓用正則表達式匹配,==可能只使用全局模式匹配AFAIK。