Esempio n. 1
0
def get_notify_authors_message(request, env, current_build):
    try:
        last_succ_deploy = get_last_ngapp2_deploy(request, env['envName'],
                                                  env['stageName'])
        last_build = builds_helper.get_build(request,
                                             last_succ_deploy['buildId'])
        start_commit = current_build.get('commit')
        end_commit = last_build.get('commit')
        repo = last_build['repo']
        commits = common.get_commits_between(request,
                                             repo=repo,
                                             startSha=start_commit,
                                             endSha=end_commit)
        authors = set()
        for commit in commits:
            author = commit.get('author')
            if not author or author.lower() == "unknown":
                continue
            authors.add("<@{}>".format(author))
        mentions = ",".join(authors)
        return "This deploy features {} commits from the " \
               "following pingineers: {}. See changes <{}|here>".format(len(commits), mentions,
                                                                        get_ngapp2_compare_deploy_url(
                                                                            current_build.get("id"),
                                                                            last_build.get("id")))
    except:
        logger.error(traceback.format_exc())
        return ""
Esempio n. 2
0
def get_notify_authors_message(request, env, current_build):
    try:
        last_succ_deploy = get_last_ngapp2_deploy(request, env['envName'], env['stageName'])
        last_build = builds_helper.get_build(request, last_succ_deploy['buildId'])
        start_commit = current_build.get('commit')
        end_commit = last_build.get('commit')
        repo = last_build['repo']
        commits = common.get_commits_between(request, repo=repo, startSha=start_commit,
                                             endSha=end_commit)
        authors = set()
        for commit in commits:
            author = commit.get('author')
            if not author or author.lower() == "unknown":
                continue
            authors.add("<@{}>".format(author))
        mentions = ",".join(authors)
        return "This deploy features {} commits from the " \
               "following pingineers: {}. See changes <{}|here>".format(len(commits), mentions,
                                                                        get_ngapp2_compare_deploy_url(
                                                                            current_build.get("id"),
                                                                            last_build.get("id")))
    except:
        logger.error(traceback.format_exc())
        return ""