Travis CI is a hosted continuous integration service used to build and test software projects hosted on GitHub and Bitbucket.
.travis.yml
file: Defines the CI/CD pipelinelanguage: ruby
rvm:
- 2.7
script:
- bundle exec rake test
os: linux
dist: focal
before_install
install
before_script
script
after_success
or after_failure
before_deploy
(optional)deploy
(optional)after_deploy
(optional)after_script
before_install:
- sudo apt-get update
install:
- bundle install
before_script:
- bundle exec rake db:create
script:
- bundle exec rake test
after_success:
- coveralls
language: ruby
rvm:
- 2.7
- 3.0
language: node_js
node_js:
- 14
- 16
language: python
python:
- "3.8"
- "3.9"
env:
- DB=postgres
- SH=bash
- PACKAGE_VERSION="1.0.*"
Use travis encrypt
command:
travis encrypt SOMEVAR="secretvalue" --add env.global
script:
- echo $DB
deploy:
provider: heroku
api_key: "YOUR API KEY"
app: "YOUR APP NAME"
deploy:
provider: s3
access_key_id: "YOUR AWS ACCESS KEY"
secret_access_key: "YOUR AWS SECRET KEY"
bucket: "S3 Bucket"
skip_cleanup: true
cache:
directories:
- $HOME/.cache/pip
- node_modules
language: node_js
cache: npm
language: python
python:
- "3.8"
- "3.9"
env:
- DJANGO=2.2
- DJANGO=3.0
matrix:
exclude:
- python: "3.8"
env: DJANGO=3.0
notifications:
email:
recipients:
- one@example.com
- other@example.com
on_success: never
on_failure: always
notifications:
slack: "YOUR SLACK AUTH TOKEN"
services:
- docker
before_install:
- docker build -t myapp .
- docker run -d -p 127.0.0.1:80:4567 myapp
after_success:
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker push USER/REPO
services:
- mysql
before_script:
- mysql -e 'CREATE DATABASE IF NOT EXISTS test;'
services:
- postgresql
before_script:
- psql -c 'CREATE DATABASE travis_ci_test;' -U postgres
branches:
only:
- main
- stable
jobs:
include:
- if: branch = main
script: npm run deploy
body='{
"request": {
"branch":"main"
}}'
curl -s -X POST -H "Content-Type: application/json" -H "Accept: application/json" -H "Travis-API-Version: 3" -H "Authorization: token YOUR-TRAVIS-API-TOKEN" -d "$body" https://api.travis-ci.com/repo/OWNER%2FREPO/requests
curl -H "Travis-API-Version: 3" -H "Authorization: token YOUR-TRAVIS-API-TOKEN" https://api.travis-ci.com/repo/OWNER%2FREPO/builds
.travis.yml
file simple and readableUse Travis CI CLI:
travis lint
Add to your .travis.yml
:
before_install:
- env
- ls -la
2024 © All rights reserved - buraxta.com