seantis/travis_after_all

Name: travis_after_all

Owner: seantis gmbh

Description: This is travis helper to run particular work only once in matrix

Created: 2017-03-17 08:44:37.0

Updated: 2017-03-17 08:44:38.0

Pushed: 2017-01-15 12:38:13.0

Homepage: null

Size: 26

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

travis_after_all

Build Status

This is a Travis CI helper to run particular work only once in matrix.

This is a workaround for: https://github.com/travis-ci/travis-ci/issues/929

Dependencies

This script assumes an environment variable called GITHUB_TOKEN is always available for Travis CI builds. This token will be used for retrieving a temporary Travis token for the LEADER job to poll Travis about the state of the other jobs.

Read more about creating a suitable GitHub token here.

Once you have a suitable token available, you can make sure it ends up encrypted in your .travis.yml file by doing:

install travis
is encrypt GITHUB_TOKEN="github-token" --add

After this step you will find new lines in your Travis CI config:


obal:
secure: "encrypted-github-token"
Usage

The main goal of this script to have a single publish when a build has several jobs. Currently the first job is a leader, meaning a node that will do the publishing.

An example .travis.yml shows how to ensure that all_succeeded or all_failed:


pt:
curl -Lo travis_after_all.py https://raw.github.com/dmakhno/travis_after_all/master/travis_after_all.py
r_success:
python travis_after_all.py https://api.travis-ci.com
export $(cat .to_export_back)
|
  if [ "$BUILD_LEADER" = "YES" ]; then
    if [ "$BUILD_AGGREGATE_STATUS" = "others_succeeded" ]; then
      echo "All jobs succeeded! PUBLISHING..."
    else
      echo "Some jobs failed"
    fi
  fi
r_failure:
python travis_after_all.py https://api.travis-ci.com
export $(cat .to_export_back)
|
  if [ "$BUILD_LEADER" = "YES" ]; then
    if [ "$BUILD_AGGREGATE_STATUS" = "others_failed" ]; then
      echo "All jobs failed"
    else
      echo "Some jobs failed"
    fi
  fi
r_script:
echo leader=$BUILD_LEADER status=$BUILD_AGGREGATE_STATUS
Limitations/Todo

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.