Skip to content

On a schedule

Get a weekly pull request report per repo

Each Monday you see how many pull requests were opened, merged and declined in every repo last week, and by whom.

Runs
On a schedule
Apps
Bitbucket
AI
Not needed
Access
read:repository:bitbucket, read:pullrequest:bitbucket

Send this to your assistant

Create a ClickRuntime automation: every Monday at 9am, email me a table of last week's Bitbucket pull requests for each repo in the acme workspace: how many were opened, merged and declined, with the authors.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

An engineering manager running three or four Bitbucket repositories usually answers the question of how the team is doing from gut feeling. Maybe one repo has stalled, maybe one person is carrying all the reviews, maybe a pile of declined pull requests means requirements keep changing. Nobody has time to open each repository on Monday morning and count by hand, so the pattern only shows up when a deadline slips.

Every Monday, ClickRuntime goes through the repositories in your workspace, reads recent pull requests newest-updated first and stops paging once it reaches ones last updated more than seven days ago. It then counts how many were opened, merged and declined in each repo and by each author, and emails the totals. Date filtering is done on the ClickRuntime side because Bitbucket's query filter on dates is not documented.

Team leads, directors and consultants who need a weekly engineering pulse without a metrics platform find it useful.

What you get out of it

  • Throughput you can compare week to week

    Seeing merged counts per repository each Monday turns a vague feeling about velocity into numbers. A drop from twelve merges to three stands out immediately and prompts the right question.

  • Uneven workloads become visible

    Per-author counts show who is opening and merging most of the work. A manager can spot an overloaded engineer or a quiet one before burnout or disengagement turns into a resignation.

  • Declined pull requests flag churn

    A rising number of declined pull requests often means unclear specs or misaligned priorities. Catching that in a weekly count lets you fix the planning problem instead of blaming the code.

  • A lightweight record for status reports

    The Monday email can be pasted straight into a stakeholder update or a sprint review. Nobody spends an hour gathering numbers for a meeting that needs only three of them.

  • No metrics tool to buy or maintain

    Engineering analytics products take setup and a budget. A scheduled count over your own Bitbucket data gives the headline numbers with nothing extra to administer. Small teams especially benefit, because a count over data you already own costs nothing extra.

How it works

What happens, step by step

  1. Every Monday at 9, ClickRuntime goes through each repository in your Bitbucket workspace.

  2. It gathers the pull requests updated in the last seven days.

  3. It counts how many were opened, merged and declined in each repository, and who wrote them.

  4. The table arrives in your inbox.

Before it runs live

  • Connect Bitbucket

What you get

RunsOn a schedule
Get a weekly pull request report per repotoday, 9:00Succeeded
Email · Weekly PR reportrepo | opened | merged | declined | authors web-app | 6 | 5 | 1 | Alex Kim, Sam Patel

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other Bitbucket steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
get_a_weekly_merged_pull_request_report.pyexample
from collections import Counter
from datetime import datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, http, notify

BB = "https://api.bitbucket.org/2.0"

def bb(path, **params):
    resp = http.get(f"{BB}{path}", headers={"Authorization": f"Bearer {credentials.secret('BITBUCKET_TOKEN')}"}, params=params)
    resp.raise_for_status()
    return resp.json()

@on_trigger
def run(event):
    cutoff = datetime.now(timezone.utc) - timedelta(days=7)
    rows = ["repo | opened | merged | declined | authors"]
    for repo in bb("/repositories/acme", pagelen=100)["values"]:
        counts, authors = Counter(), set()
        page = bb(f"/repositories/acme/{repo['slug']}/pullrequests", q='state="MERGED" OR state="DECLINED" OR state="OPEN"',
                  sort="-updated_on", pagelen=50)
        for p in page["values"]:
            if datetime.fromisoformat(p["updated_on"]) < cutoff:
                break
            counts["opened"] += datetime.fromisoformat(p["created_on"]) >= cutoff
            counts[p["state"].lower()] += 1
            authors.add(p["author"]["display_name"])
        if authors:
            rows.append(f"{repo['slug']} | {counts['opened']} | {counts['merged']} | {counts['declined']} | {', '.join(sorted(authors))}")
    notify.email_me("Bitbucket pull requests last week", "\n".join(rows))
    return {"repos": len(rows) - 1}

FAQ

Common questions

Why is date filtering done after fetching rather than in the Bitbucket query?
Bitbucket's documentation does not describe date filtering in the pull request query parameter, so the workflow sorts by most recently updated and checks each updated_on value itself, stopping once pull requests are older than seven days. It is slightly more work per run but behaves predictably.
Does a pull request merged this week but opened last month count as opened?
Opened counts follow when a pull request was created, and merged counts follow when it merged, so an old pull request merged last week appears under merged and not opened. Each pull request is classified by its state and relevant date within the seven-day window.
Can it report on only some repositories?
Yes. The workflow lists repositories in the workspace, and you can restrict it to a named set, for example only the repositories your team owns. Mention the repository names in chat and check the updated version before approving.
What permissions does it need?
read:repository:bitbucket, read:pullrequest:bitbucket. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (on a schedule). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Get a weekly pull request report per repo” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.