Example #1
0
    def process(self, assigner, assignee, build_number, issue, title, apk_path, squashed_branch):
        hipchat_assigner = user_db.get_user_for_service(assigner, 'hipchat')
        hipchat_assignee = user_db.get_user_for_service(assignee, 'hipchat')
        jenkins_job_url = builder_tool.get_build_path(build_number)
        jira_issue_url = issue_tracker_tool.get_issue_url(issue.key)
        issue_tracker_tool.comment_issue(issue.key, "Build {0}, [Download Link|{1}]".format(build_number, apk_path))
        im_tool.send_message(hipchat_assigner, "Build {0} ({1}) is successful, listing MRs... [{2}, {3}]".format(build_number, issue, jenkins_job_url, jira_issue_url))
        im_tool.send_message(hipchat_assignee, "Build {0} ({1}) is successful, MRs are coming your way... [{2}, {3}]".format(build_number, issue, jenkins_job_url, jira_issue_url))

        def open_mr():
            git_tool.fetch(['master'])
            if git_tool.is_branch_diverged('origin/master'):
                mr = cr_tool.create_mr(git_tool.get_repo(), squashed_branch, assignee, "WIP: "+title)
                cr_tool.approve_build(git_tool.get_repo(), squashed_branch, build_number)


                im_tool.send_message(hipchat_assigner, "MR {0} has been assigned to @{1}".format(mr, hipchat_assignee))
                im_tool.send_message(hipchat_assignee, "Hey, @{0} sent you a MR to review: {1}".format(hipchat_assigner, mr))
                return mr, None
            return None, None


        resolve_errors(git_tool.recurse_submodules(open_mr), title="Opening MRs...")
        update_jira(partial(issue_tracker_tool.send_to_cr, issue.key, user_db.get_user_for_service(assignee, 'jira')),
                    'Requested code review')
Example #2
0
 def process(self, assigner, assignee, build_number, issue, title, apk_path, squashed_branch):
     print "Sending notification to initiator"
     jenkins_job_url = builder_tool.get_build_path(build_number)
     jira_issue_url = issue_tracker_tool.get_issue_url(issue.key)
     issue_tracker_tool.comment_issue(issue.key, "Build {0}, [Download Link|{1}]".format(build_number, apk_path))
     hipchat_assigner = user_db.get_user_for_service(assigner, 'hipchat')
     im_tool.send_message(hipchat_assigner, "Build {0} ({1}) is successful, you can either wait for tests to finish, or be hasty and land it now! [{2}, {3}]"
                               .format(build_number, issue, jenkins_job_url, jira_issue_url))
Example #3
0
    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)))