oss-fuzz/infra/gcb/cancel.py

41 lines
827 B
Python
Raw Normal View History

#!/usr/bin/python2
"""Cancels project build on Google Cloud Builder.
Usage: cancel.py <build_id>
"""
import base64
import collections
import datetime
import os
import subprocess
import sys
import time
import urllib
import yaml
from oauth2client.client import GoogleCredentials
from oauth2client.service_account import ServiceAccountCredentials
from googleapiclient.discovery import build
2018-07-27 03:32:09 +00:00
def usage():
2018-07-27 03:32:09 +00:00
sys.stderr.write('Usage: ' + sys.argv[0] + ' <build_id>\n')
exit(1)
def main():
if len(sys.argv) != 2:
usage()
build_id = sys.argv[1]
credentials = GoogleCredentials.get_application_default()
cloudbuild = build('cloudbuild', 'v1', credentials=credentials)
print cloudbuild.projects().builds().cancel(
2017-04-05 21:38:03 +00:00
projectId='oss-fuzz', id=build_id, body={}).execute()
2018-07-27 03:32:09 +00:00
if __name__ == '__main__':
main()