Skip to content

Instantly share code, notes, and snippets.

@tonyvince
Last active May 14, 2020 12:42
Show Gist options
  • Save tonyvince/d0e67c3020284bbb1c61c2cbb7519d99 to your computer and use it in GitHub Desktop.
Save tonyvince/d0e67c3020284bbb1c61c2cbb7519d99 to your computer and use it in GitHub Desktop.
Ruby script to automatically restart a travis-ci build
# The script below checks a given build is running or not
# and restarts the build of not running
#
# This script is used to run a particular build for the duration of a day
# to catch all randombly failing tests
#
# To get access token, see here https://github.com/travis-ci/travis.rb#token
# ================================
# for private repositories users
require 'travis/pro'
Travis::Pro.access_token = 'your access token'
repo = Travis::Pro::Repository.find('organization/repository')
build = repo.build(n) # where n is the travis-ci build number
build.restart unless build.running?
# ================================
# ================================
# for public repositories
require 'travis'
Travis.access_token = 'your access token'
repo = Travis::Repository.find('username/repository')
build = repo.build(n) # where n is the travis-ci build number
build.restart unless build.running?
# ================================
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment