def trigger_build(repo, branch): """ Sends a request to Travis, rebuilding the content """ if not app.config["TRAVIS_REPO_SLUG"] or not app.config["TRAVIS_TOKEN"]: return t = TravisPy(app.config['TRAVIS_TOKEN']) # it doesn't make sense for multiple builds of the same branch to run at the same time # so if some are still running for our target branch, lets stop them for build in t.builds(slug=app.config["TRAVIS_REPO_SLUG"]): if not build.pull_request and build.pending and build.commit.branch == app.config[ "NAUCSE_BRANCH"]: build.cancel() # unfortunately, TravisPy doesn't provide a method to trigger a build, so triggering manually: requests.post("https://api.travis-ci.org/repo/{}/requests".format( urllib.parse.quote_plus(app.config["TRAVIS_REPO_SLUG"])), json={ "request": { "branch": app.config["NAUCSE_BRANCH"], "message": f"Triggered by {repo}/{branch}" } }, headers={ "Authorization": f"token {app.config['TRAVIS_TOKEN']}", "Travis-API-Version": "3" })
def stop_all_builds(): for username, repo_name, github_token, travis_ci_token in CREDS: travis_session = TravisPy(token=travis_ci_token) builds = travis_session.builds(slug="{}/{}".format(username, repo_name)) for build in builds: if not build.finished: success = build.cancel() url = calculate_build_url(username, repo_name, build) if success: logger.info("Build {} aborted".format(url)) else: logger.error("Build {} fails to abort".format(url))
def main(): travis = TravisPy() revision = check_output(["git", "rev-parse", "HEAD"]).strip() build_passed = False for build in travis.builds(slug="datawire/mdk"): if build.commit.sha == revision: if build.passed: build_passed = True break else: error("Found the build but it has not passed.\n Build state: " + build.state + "\n Build URL: https://travis-ci.org/datawire/mdk/builds/" + str(build.id)) if not build_passed: error("No matching build found on Travis CI.")
def main(): travis = TravisPy() revision = check_output(["git", "rev-parse", "HEAD"]).strip() build_passed = False for build in travis.builds(slug="datawire/mdk"): if build.commit.sha == revision: if build.passed: build_passed = True break else: error( "Found the build but it has not passed.\n Build state: " + build.state + "\n Build URL: https://travis-ci.org/datawire/mdk/builds/" + str(build.id)) if not build_passed: error("No matching build found on Travis CI.")
'-q', '--quiet', action='store_true', default=False, help="Quiet means only print from logs, with no extra build info") args = parser.parse_args() # Slow to import, no need for --help from travispy import TravisPy # pip install travispy t = TravisPy() for number in range(args.number - 100, args.number): # print(number) build = t.builds(slug=args.slug, number=number)[0] # print(build['started_at']) # print(build['finished_at']) start_seconds = iso2epoch(build['started_at']) finish_seconds = iso2epoch(build['finished_at']) # print(start_seconds) # print(finish_seconds) seconds = finish_seconds - start_seconds # print(seconds) m, s = divmod(seconds, 60) print("%02dm%02ds\t%d" % (m, s, number)) # job_ids = sorted(build.job_ids) # # first_started_at = sys.maxint
'grosser/parallel_tests', 'mongodb/mongo-python-driver', 'scambra/devise_invitable', 'dennisreimann/ioctocat', 'cython/cython', 'mongomapper/mongomapper', 'publify/publify' ] t = TravisPy() builds_result = [] for project in projects: builds = t.builds(slug=project, event_type='pull_request') labels = ['project', 'pull_number', 'started_at', 'finished_at', 'branch', 'build_status'] count = 1 print ' {:_<6} {:_<26} {:_^12} {:_^8} {:_^8} '.format('','','','','') print '|{:^6}|{:^26}|{:^12}|{:^8}|{:^8}|'.format('#','project','pull_number', 'branch', 'status') while builds: for build in builds: print '|{:_<6}|{:_<26}|{:_^12}|{:_^8}|{:_^8}|'.format('','','','','') print '|{:^6}|{:^26}|{:^12}|{:^8}|{:^8}|'.format(count, project, build.pull_request_number, build.commit.branch, build.color) data = [project, build.pull_request_number, build.started_at, build.finished_at, build.commit.branch, build.color]
'-q', '--quiet', action='store_true', default=False, help="Quiet means only print from logs, with no extra build info") args = parser.parse_args() build_no, job_no = split_build_number(args.number) # Slow to import, no need for --help from travispy import TravisPy # pip install travispy t = TravisPy() # repo = t.repo(args.slug) build = t.builds(slug=args.slug, number=build_no)[0] job_ids = sorted(build.job_ids) for job_id in job_ids: job = t.job(job_id) if job_no: # Job number specified, only print that one if str(args.number) != job.number: continue if not args.quiet: print() print(f"#{job.number}") log = t.log(job.log_id)