Пример #1
0
def add_release(body):
    session = g.db.session
    r = Release(product=body['product'],
                version=body['version'],
                branch=body['branch'],
                revision=body['revision'],
                build_number=body['build_number'],
                release_eta=body.get('release_eta'),
                status='scheduled',
                partial_updates=body.get('partial_updates'))
    try:
        r.generate_phases(
            partner_urls=current_app.config.get('PARTNERS_URL'),
            github_token=current_app.config.get('GITHUB_TOKEN'),
        )
        session.add(r)
        session.commit()
        release = r.json
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)

    notify_via_irc(
        f'New release ({r.product} {r.version} build{r.build_number}) was just created.'
    )

    return release, 201
Пример #2
0
def add_release(body):
    # we must require scope which depends on product
    required_permission = f'{SCOPE_PREFIX}/add_release/{body["product"]}'
    if not current_user.has_permissions(required_permission):
        user_permissions = ', '.join(current_user.get_permissions())
        abort(401, f'required permission: {required_permission}, user permissions: {user_permissions}')

    session = current_app.db.session
    product = body['product']
    r = Release(
        product=product,
        version=body['version'],
        branch=body['branch'],
        revision=body['revision'],
        build_number=body['build_number'],
        release_eta=body.get('release_eta'),
        status='scheduled',
        partial_updates=body.get('partial_updates'),
        product_key=body.get('product_key'),
    )
    try:
        r.generate_phases(
            partner_urls=current_app.config.get('PARTNERS_URL'),
            github_token=current_app.config.get('GITHUB_TOKEN'),
        )
        session.add(r)
        session.commit()
        release = r.json
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)

    notify_via_irc(product, f'New release ({product} {r.version} build{r.build_number}) was just created.')

    return release, 201
Пример #3
0
def add_release(body):
    # we must require scope which depends on product
    required_permission = f'{SCOPE_PREFIX}/add_release/{body["product"]}'
    if not current_user.has_permissions(required_permission):
        user_permissions = ", ".join(current_user.get_permissions())
        abort(
            401,
            f"required permission: {required_permission}, user permissions: {user_permissions}"
        )

    product = body["product"]
    branch = body["branch"]

    product_disabled = branch in get_disabled_products().get(product, [])
    if current_user.type == AuthType.TASKCLUSTER and product_disabled:
        abort(401, "Taskcluster based submissions are disabled")

    session = current_app.db.session
    partial_updates = body.get("partial_updates")
    if partial_updates == "auto":
        if product not in [
                Product.FIREFOX.value, Product.DEVEDITION.value
        ] or branch not in ["try", "releases/mozilla-beta", "projects/maple"]:
            abort(400, "Partial suggestion works for automated betas only")

        partial_updates = _suggest_partials(product=product, branch=branch)
    release = Release(
        branch=branch,
        build_number=body["build_number"],
        partial_updates=partial_updates,
        product_key=body.get("product_key"),
        product=product,
        release_eta=body.get("release_eta"),
        repo_url=body.get("repo_url", ""),
        revision=body["revision"],
        status="scheduled",
        version=body["version"],
    )
    try:
        release.generate_phases()
        session.add(release)
        session.commit()
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)
    except TaskclusterRestFailure as e:
        # Report back Taskcluster failure for better visibility of the actual
        # issue. Usually it happens when we cannot find the indexed task.
        abort(400, str(e))

    logger.info("New release of %s", release.name)
    notify_via_irc(product, f"New release of {release.name}")

    return release.json, 201
Пример #4
0
def add_release(body):
    # we must require scope which depends on product
    required_permission = f'{SCOPE_PREFIX}/add_release/{body["product"]}'
    if not current_user.has_permissions(required_permission):
        user_permissions = ", ".join(current_user.get_permissions())
        abort(
            401,
            f"required permission: {required_permission}, user permissions: {user_permissions}"
        )

    product = body["product"]
    branch = body["branch"]

    product_disabled = branch in get_disabled_products().get(product, [])
    if current_user.type == AuthType.TASKCLUSTER and product_disabled:
        abort(401, "Taskcluster based submissions are disabled")

    session = current_app.db.session
    partial_updates = body.get("partial_updates")
    if partial_updates == "auto":
        if product not in [
                Product.FIREFOX.value, Product.DEVEDITION.value
        ] or branch not in ["try", "releases/mozilla-beta", "projects/maple"]:
            abort(400, "Partial suggestion works for automated betas only")

        partial_updates = _suggest_partials(product=product, branch=branch)
    r = Release(
        product=product,
        version=body["version"],
        branch=branch,
        revision=body["revision"],
        build_number=body["build_number"],
        release_eta=body.get("release_eta"),
        status="scheduled",
        partial_updates=partial_updates,
        product_key=body.get("product_key"),
    )
    try:
        r.generate_phases(partner_urls=current_app.config.get("PARTNERS_URL"),
                          github_token=current_app.config.get("GITHUB_TOKEN"))
        session.add(r)
        session.commit()
        release = r.json
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)

    notify_via_irc(
        product,
        f"New release ({product} {r.version} build{r.build_number}) was just created."
    )

    return release, 201
Пример #5
0
def add_release(body):
    session = flask.g.db.session
    r = Release(product=body['product'],
                version=body['version'],
                branch=body['branch'],
                revision=body['revision'],
                build_number=body['build_number'],
                release_eta=body.get('release_eta'),
                status='scheduled',
                partial_updates=body.get('partial_updates'))
    try:
        r.generate_phases(
            partner_urls=flask.current_app.config.get('PARTNERS_URL'),
            github_token=flask.current_app.config.get('GITHUB_TOKEN'),
        )
        session.add(r)
        session.commit()
        return r.json, 201
    except UnsupportedFlavor as e:
        raise BadRequest(description=e.description)