Travis - GradedJestRisk/cicd-training GitHub Wiki

Table of Contents

General

CLI

Install

  • install ruby sudo apt-get install ruby-dev
  • then follow here
  • login: travis login
  • get history: travis history -d
  • get last build: travis status

Environment variables

Used for secrets:

Travis file (.travis.yml)

Cheatsheet

Always check .travis.yml file: if invalid, no build will be triggered..

  • locally: travis lint .travis.yml , you should get Hooray, .travis.yml looks valid :)
  • with web YAML linter - but you will just have YAML checked, not Travis-specific markups

Steps

Overview

  • login DockerHub: use environment variables echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_ID" --password-stdin
  • push image to DockerHub: docker push <TAG>

Template

Structure

sudo: required
services:
        - <SERVICE_NAME>
before_install:
        - <COMMAND>

script:
        - <COMMAND>

deploy:   
        provider:   <PROVIDER_NAME>
        (..)
        on:
                branch: master
        (..)

Sample: Build a docker image, and deploy it to ASW BS

sudo: required
services:
        - docker

before_install:
        - docker build -t <TAG> -f <DOCKER_FILE> .
script:
        - docker run <TAG>
deploy:   
        provider:   elasticbeanstalk
        region:      ""                                                 
        app:         ""   
        env:         ""   
        bucket_name: ""       
        bucket_path: "<APPLICATION_NAME>"
        on:
                branch: master
        access_key_id:  $AWS_ACCESS_KEY
        secret_access_key:
                secure: $AWS_SECRET_KEY

Be notified when pipeline fail

This is done by default on email, can we also use Travis CLI for this or run Travis locally

⚠️ **GitHub.com Fallback** ⚠️