Travis CI内联Bash脚本

时间:2017-08-08 17:38:50

标签: travis-ci

我有以下Travis CI yml文件片段:

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 个答案:

答案 0 :(得分:3)

"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

此外,您的第二次检查可能没有做您想要的。使用=~运算符启用正则表达式匹配,==可能只使用glob模式匹配,AFAIK。