Create Asana tasks from open Bitbucket pull requests
A Bitbucket + Asana agent flow
Open pull requests pile up in Bitbucket while the people tracking delivery work from an Asana board and never see the queue. A PR sits without a reviewer because nobody planning the week knows it's waiting. This recipe has your agent read open pull requests with getPullRequests and open a matching Asana task for each, so review work shows up on the board your team actually checks. It carries the PR title, the author, the source branch, and a link, and batches them through create_tasks. Bitbucket answers the agent's call rather than pushing, so the agent reads on a schedule and only PRs that don't already have a task become one.
The flow
getPullRequestsGets pull requests for a repository, optionally filtered by state (OPEN, MERGED, DECLINED, SUPERSEDED).
create_tasksCreates up to 50 tasks with assignments, dates, and custom fields.
Step by step
- Scope the repo and the project
Name the Bitbucket workspace and repository, and the Asana project that tracks review work. Filter getPullRequests to OPEN so merged and declined PRs don't spawn tasks.
- Read open pull requests
The agent calls getPullRequests with state OPEN, reading each PR's title, author, source and destination branch, and its URL.
- Create the tasks in a batch
It maps each open PR to a task and calls create_tasks, which takes up to 50 at once, with the PR title, a description naming the author and branch and linking the PR, and a reviewer as assignee if you map one.
- Record what's already tracked
Store each PR ID against the Asana task it created. Next run the agent skips PRs that already have a task, so re-running doesn't duplicate the board, and you can close the task when the PR leaves OPEN.
Tell your agent
Each morning, get open pull requests in acme/api on Bitbucket. For any that don't already have an Asana task, create tasks in the Code Review project with the PR title, a description naming the author and branch and linking the PR, and a due date of end of day. Don't recreate tasks for PRs you've already tracked.
Setup
This flow needs both servers connected to your agent. Follow each install guide:
Worth knowing
- getPullRequests returns the requested reviewers on a PR, not whether anyone has approved it. If you want the task to reflect approval, you'd read getPullRequestActivity per PR, since the list alone doesn't carry approval state.
- create_tasks needs an Asana project or workspace GID, and a user GID for an assignee, not a name. Resolve those once with get_projects and get_users and pass the IDs.
- The batch caps at 50 tasks per call. On a busy repo's first backfill, have the agent page the PR list and chunk the creates so it stays under the limit.
Questions
- Does merging the PR close the Asana task?
- Not on its own. This recipe creates tasks. To close them, add a step that reads getPullRequests filtered to MERGED or DECLINED and updates the task you stored for that PR ID.
- How does it avoid creating the same task twice?
- By storing each Bitbucket PR ID next to the Asana task it created. Each run it reads open PRs, drops the ones already mapped, and only creates tasks for the rest.