def __call__(self, build_no, project="Android,Context,Discovery"): check_root() tag = "cibuild_%s" % build_no resolve_errors(git_tool.recurse_submodules(lambda: git_tool.fetch()), **FETCH_HANDLING) # make sure we get the correct week even if we freeze on Sunday now = datetime.datetime.now() day = datetime.timedelta(days=1) cal = (now+day).isocalendar() year = cal[0] pulse = cal[1] branchname = "rc-%d-%02d" % (year, pulse) resolve_errors(git_tool.recurse_submodules(lambda: git_tool.new_branch(branchname, tag)), title="Freezing into %s" % branchname) resolve_errors(git_tool.recurse_submodules(lambda: git_tool.forcepush(branchname)), title="Pushing %s" % branchname) def protect(): repo = git_tool.get_repo() success = cr_tool.protect_branch(repo, branchname) return None, None if success else "Failed" def mark_issues_to_rc(): """ mark issues as IN_RC: we search Jira for all issues with IN_MASTER status and then exclude issues not found in the git log of the branchname """ jql = 'project in ({0}) and status="{1}"'.format(project, issue_tracker_tool.JiraStatus.LANDED_IN_MASTER) issues = issue_tracker_tool.search(jql) keys_in_master = [issue.key for issue in issues] exclude = issues_not_in_branch(branchname) print 'excluding issues not in {0}'.format(branchname), exclude for key in set(keys_in_master) - set(exclude): print "{0}: marking in rc".format(key) issue_tracker_tool.mark_in_rc(key, branchname) resolve_errors(git_tool.recurse_submodules(protect), title="Protecting %s" % branchname) mark_issues_to_rc() print BOLD("Initiating a build") rc_build_no, success = builder_tool.build_launcher(branch=branchname, profiles=["Debug"], block=True, gitlab_token=cr_tool.get_gitlab_token(), split_apks="yes") if success: print BOLD("Updating Rollout") rollout_tool.create_release(rc_build_no, 0) # freezing a release is always with distribution=0 print BOLD("Sending event to Timebox") timebox_tool.send_event('freeze', rc_build_no, '0', pulse, builder_tool.get_build_path(str(rc_build_no)))
def build(self, post_build_task, assignee=None, branch=None, wait=False): print BOLD("Building...") builder_tool.build_launcher(branch=branch, profiles=["Debug"], block=wait, gitlab_token=cr_tool.get_gitlab_token(), assignee=assignee, split_apks="no", post_build_task=post_build_task)