def create_release(environment, branches): """ Creates a new release from latest builds and assigns it to staging """ data = {} env = get_object('environment', name=environment) # Get our build ids for this release from the build_latest endpoint data['builds'] = [i['id'] for i in get_latest_builds(branches=branches)] # if we current release builds matches new latest skip. new_builds = sorted(data['builds']) print 'Builds Found: %s' % new_builds print env['raw_release'] release_builds = sorted(env['raw_release'].get('builds', [])) if new_builds == release_builds: print 'New release matches current release "%s", skipping ...' % \ env['raw_release'].get('name') return # For now set our initial status to 1 data['status'] = 1 release = create_object('release', data) url = urlparse.urljoin(api, 'environment/%s/' % env['id']) env['release'] = release['id'] response = put(url, env, username=username, password=password) json = response.json() print json
def add_build_blocker(build_id, build_hash, blocker): """ Appends a blocker to a build """ build_blocker = get_object('build_blocker', name=blocker) if build_blocker: build = get_object('build', build_id=build_id, build_hash=build_hash) if build: if build_blocker['id'] in build['blockers']: print 'blocker already set..' return build['blockers'].append(build_blocker['id']) url = urlparse.urljoin(api, 'build/%s/' % build['id']) response = put(url, build, username=username, password=password) json = response.json() print json