我想为两个不同的构建脚本运行Travis CI构建。例如:
./prepare.sh
mvn verify -Psystem-tests
./prepare.sh
mvn verify -Pintegration-tests
在documentation中,我看到构建矩阵功能正是我所需要的,但那里的示例仅涉及如何在不同环境中创建矩阵。
如何在不同的构建命令上创建这样的矩阵?
这是我当前的.travis.yml
:
language: java
cache:
directories:
- $HOME/.m2
script:
- ./prepare.sh
- mvn verify -Psystem-tests
- mvn clean verify -Pintegration-tests
答案 0 :(得分:4)
在matrix
部分,您可以指定:
命令本身:
matrix:
- env: MAVEN_SCRIPT="mvn verify -Psystem-tests"
- env: MAVEN_SCRIPT="mvn clean verify -Pintegration-tests"
script:
- ./prepare.sh
- $MAVEN_SCRIPT
要运行哪个命令,然后运行if
:
matrix:
- env: MAVEN_TESTS=system
- env: MAVEN_TESTS=integration
script:
- ./prepare.sh
- if [ "$MAVEN_TESTS" == "system" ]; then mvn verify -Psystem-tests; fi
- if [ "$MAVEN_TESTS" == "integration" ]; then mvn clean verify -Pintegration-tests; fi
区分测试的具体部分:
matrix:
- env: MAVEN_TEST_CLEANLINESS="" MAVEN_TESTS=system
- env: MAVEN_TEST_CLEANLINESS=clean MAVEN_TESTS=integration
script:
- ./prepare.sh
- mvn $MAVEN_CLEANLINESS verify -P$MAVEN_TESTS-tests