2013-10-14 02:36:58 +00:00
---
title: Travis.yml
2018-12-06 22:15:40 +00:00
category: Devops
2020-07-05 13:13:06 +00:00
prism_languages: [yaml]
intro: |
Quick reference for [Travis CI ](https://travis-ci.org ) yaml configuration. See [official documentation ](https://docs.travis-ci.com/user/customizing-the-build/ ).
2013-05-29 12:19:07 +00:00
---
2020-07-05 13:13:06 +00:00
## Reference
{:.-three-column}
2013-05-29 12:19:07 +00:00
2020-07-05 13:13:06 +00:00
### Node.js
```yaml
2015-10-15 10:55:41 +00:00
language: node_js
node_js:
2020-07-05 13:13:06 +00:00
- '4'
2015-10-15 10:55:41 +00:00
```
2013-05-29 12:19:07 +00:00
2020-07-05 13:13:06 +00:00
Defaults install to `npm install` , and defaults test to `npm test` .
2013-05-29 12:19:07 +00:00
### Ruby
2020-07-05 13:13:06 +00:00
```yaml
2015-10-15 10:55:41 +00:00
language: ruby
rvm:
2020-07-05 13:13:06 +00:00
- 2.0.0
- 1.9.3
- 1.8.7
2015-10-15 10:55:41 +00:00
```
2020-07-05 13:13:06 +00:00
Defaults install to `bundle install` , defaults test to `rake` .
2015-10-15 10:55:41 +00:00
### Build lifecycle
2020-07-05 13:13:06 +00:00
| Lifecycle |
| ---------------------------------- |
| `before_install` |
| `install` |
| --- |
| `before_script` |
| `script` |
| --- |
| `after_success` or `after_failure` |
| `after_script` |
| --- |
| `before_deploy` (optional) |
| `deploy` (optional) |
| `after_deploy` (optional) |
2013-05-29 12:19:07 +00:00
### Branches
2020-07-05 13:13:06 +00:00
```yaml
branches:
except: ['..']
only: ['master']
```
2013-05-29 12:19:07 +00:00
### Environment vars
2020-07-05 13:13:06 +00:00
```yaml
env:
- 'rack=master'
- 'rack=1.3.4'
```
2013-05-29 12:19:07 +00:00
2013-06-20 05:38:19 +00:00
### Custom test command
2013-05-29 12:19:07 +00:00
2020-07-05 13:13:06 +00:00
```yaml
script: make test
before_script: make pretest
after_script: make clean
2013-05-29 12:19:07 +00:00
2020-07-05 13:13:06 +00:00
before_script:
- make pretest1
- make pretest2
```
2013-05-29 12:19:07 +00:00
2013-06-20 05:38:19 +00:00
### Branches
2020-07-05 13:13:06 +00:00
```yaml
branches:
except:
- legacy
2013-06-20 05:38:19 +00:00
2020-07-05 13:13:06 +00:00
only:
- gh-pages
- /^deploy/
```
2013-06-20 05:38:19 +00:00
2016-08-11 10:26:59 +00:00
### Apt packages
2020-07-05 13:13:06 +00:00
```yaml
before_install:
- sudo apt-get update -q
- sudo apt-get install gcc-4.8 -y
```
2016-08-11 10:26:59 +00:00
< https: / / docs . travis-ci . com / user / installing-dependencies / >
2013-06-20 05:38:19 +00:00
### Etc
2020-07-05 13:13:06 +00:00
```yaml
gemfile:
- gemfiles/Gemfile.rails-2.3.x
- gemfiles/Gemfile.rails-3.0.x
```
2013-06-20 05:38:19 +00:00
2013-05-29 12:19:07 +00:00
### References
2022-11-01 03:29:32 +00:00
- https://about.travis-ci.org/docs/user/build-configuration/
- https://about.travis-ci.org/docs/user/languages/javascript-with-nodejs/
- https://about.travis-ci.org/docs/user/languages/ruby/