Skip to content

SOP and research for Travis CI job order

License

Notifications You must be signed in to change notification settings

yakshaveinc/travis

Repository files navigation

SOP and reference for Travis CI setup.

No builds

Create .travis.yml

Empty travis

  • script: skip stops Ruby environment from failing (build #4)
script: skip
language: minimal

Using invalid language like language: none or misspelled will default to Ruby without any errors.

Set build matrix for parallel runs

  • os key splits execution of default job into different os images (build #11)
language: minimal
os:
  - linux
  - osx

https://docs.travis-ci.com/user/multi-os/

os linux osx

  • jobs key is used to add or remove jobs
language: minimal
os:
  - linux
  - osx
jobs:
  include:
    - script: echo $TRAVIS_OS_NAME

The 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)

os matrix and single job

All jobs here are run in parallel.

  • stage to 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_NAME

default 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)

sequential jobs

If Test stage fails, then Deploy is not executed. (build #22)

failed stage

Default steps (install, script) are shared with stages

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: skip

Use stages instead of build matrix for parallel runs

When 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

About

SOP and research for Travis CI job order

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published