SOP and reference for Travis CI setup.
- Enable Travis from https://github.com/marketplace/travis-ci
- Go https://travis-ci.com/yakshaveinc/travis and hit the badge to steal it
- Insert the badge
- Empty .travis.yml starts default job in Ruby environment.
-
script: skipstops Ruby environment from failing (build #4)
script: skip-
language: minimalswitches from Ruby to alternative environment without default scripts (build #9)
language: minimalUsing invalid language like language: none or
misspelled will default to Ruby without any errors.
-
oskey splits execution of default job into different os images (build #11)
language: minimal
os:
- linux
- osxhttps://docs.travis-ci.com/user/multi-os/
-
jobskey is used to add or remove jobs
language: minimal
os:
- linux
- osx
jobs:
include:
- script: echo $TRAVIS_OS_NAMEThe script runs three steps. Two for default job on Linux and MacOS that do nothing. One from jobs section that prints
variable. The last job from jobs section executes only for Linux, because it is not affected by os matrix expansion.
(build #13)
All jobs here are run in parallel.
-
stageto run jobs in sequence
Modify .travis.yml to stage name deploy to the jobs section.
language: minimal
os:
- linux
- osx
jobs:
include:
- stage: deploy
script: echo $TRAVIS_OS_NAMEdefault job is now run in default stage called Test - the title is ommitted if there is only one stage - and the new job is
located at Deploy section.
(build #14)
If Test stage fails, then Deploy is not executed. (build #22)
Somewhat unexpected. For the script below, install section will be executed for Deploy stage.
(build #27)
language: minimal
os:
- linux
- osx
install: echo "Default install step"
script: echo "Default build step"
jobs:
include:
- stage: deploy
script: echo "Build step from Deploy"scripts steps are also shared.
(build #29)
language: minimal
os:
- linux
- osx
install: skip echo "Default install step"
script: echo "Default build step"
jobs:
include:
- stage: deploy
install: echo "Install step from Deploy"Use explicit script: skip to avoid surprises. (build #32)
language: minimal
os:
- linux
- osx
install: echo "Default install step"
script: echo "Default build step"
jobs:
include:
- stage: deploy
install: echo "Install step from Deploy"
script: skipWhen using stages, it is possible to see Travis running extra empty job as a first job in a stage. At first they might seem like default jobs that are built by Travis. But it could also be mistake in specifying stage name as a separate entry. The following snippet actually defines two jobs, and the first job runs default script command.
jobs:
include:
- stage: test
- script: echo "Hello"
Travis syntax requires that the stage name is merged with the entry of the first job. Corrected syntax.
jobs:
include:
- stage: test
script: deploy
https://travis-ci.community/t/adding-name-changes-build-jobs/2982/2





