首先由于公司用上了高大上的travis-ci商用版,一直想试着学学弄弄看。现在要写openapi的相关测试,而且要在travis-ci上集成。我就想体验一下这个过程。所以自己弄了一个public的仓库先尝试一下。
首先了解travis-ci的相关比较重要。https://docs.travis-ci.com/user/customizing-the-build/
这里首先介绍了需要集成测试的语言指定方面的问题。travis-ci的所有配置都集中在一个叫做 .travis.yml 的文件下面。这个文件告诉travis-ci
- What programming language your project uses
- What commands or scripts you want to be executed before each build (for example, to install or clone your project’s dependencies)
- What command is used to run your test suite
- Emails, Campfire and IRC rooms to notify about build failures
所以可以看出,相关的自定义处理都在这个文件里面进行写入。下面我继续翻译一下文档。
创建travis-ci一般由两步构成:
1. 安装:安装依赖和需求
2. 脚本:运行编写的脚本文件
你可以执行自定义命令在安装之前before_install或者在运行脚本之前before_script或者在运行脚本之后after_script.
在before_install里,你可以安装一些额外的需求比如说ubuntu包和一些自定义的服务。
下面太简单懒得翻了直接贴
You can perform additional steps when your build succeeds or fails using the after_success
(such as building documentation, or deploying to a custom server) or after_failure
(such as uploading log files) options. In both after_failure
and after_success
, you can access the build result using the $TRAVIS_TEST_RESULT
environment variable.
The complete build lifecycle, including three optional deployment steps and after checking out the git repository and changing to the repository directory, is:
before_install
install
before_script
script
after_success
orafter_failure
- OPTIONAL
before_deploy
- OPTIONAL
deploy
- OPTIONAL
after_deploy
after_script
如果步需要第一步安装的话 可以直接设置 install: true