Use Azure DevOps Repos¶
Agent Loops talks to Azure DevOps Repos through its own azuredevops connector (#2829), an MCP
server in the shape of the gitlab one. It works with Azure DevOps Services
(dev.azure.com and the older *.visualstudio.com addresses) and with your own Azure DevOps
Server. Agent Loops on the Mac carries it, and every Linux host installs it beside agentsd.
It has tools to read pull requests and their builds, to read a failed build's log, and to comment, and it has events that start a workflow or a wait. With the Azure DevOps connection (#3802), the Work pages list and act on the pull requests (#3803). It also has two pages of its own (#4098): Pull requests and a pull request's page. The Mac window, the Remote on iPhone and iPad, and the web page show the same pages.
Work items (Azure Boards) are not in this connector. They are the tracker's, as Linear's and Jira's issues are: see Use Azure Boards work items.
Connect Azure DevOps¶
Open Settings ▸ Connectors ▸ Connect… ▸ Azure DevOps on the Mac, or Connect Azure DevOps… on the web page's Connectors. The sheet has two ways in:
- Personal access token: the organization (
dev.azure.com/acme, or an Azure DevOps Server's collection) and a token with Code (read and write), Build (read) and Work Items (read and write). It ends on the date you gave it. - Microsoft Entra (#3921), for
dev.azure.comonly: give the organization and choose Sign In with Microsoft. Agent Loops shows a code and opens Microsoft's device page; type the code there and approve. The machine keeps the sign-in and renews it by itself, and the row says Microsoft Entra · renews by itself. It signs in with the Agent Loops app on Entra (#4873), which takes any work or school account; your organization's admin may have to approve it the first time. To use an app of your own, setAZURE_DEVOPS_CLIENT_IDin the machine's secrets to the client id of an app registration with Allow public client flows on and the Azure DevOps permissionuser_impersonation, andAZURE_DEVOPS_TENANTtoo when that app is for one tenant only.scripts/entra-app.pymakes such an app.
Before you start¶
- An Azure DevOps organization with a project and a Git repository, or your own Azure DevOps Server 2022.1 or later.
- A folder whose git remote is on it, such as
https://dev.azure.com/acme/Web%20App/_git/apporgit@ssh.dev.azure.com:v3/acme/Web%20App/app.
Add the connector¶
- In Azure DevOps, open User settings ▸ Personal access tokens and make a token for
your organization with Code: Read & write and Build: Read. To run a build's
failed jobs again (
retry_build, Retry), give it Build: Read & execute. - In Agent Loops, open Settings ▸ Agent Configuration ▸ Connectors (or a folder's Connectors page) and choose Add Connector….
- Choose the Agent Loops marketplace, then Azure DevOps, and add it.
- Fill in:
AZURE_DEVOPS_TOKEN: the token.AZURE_DEVOPS_URL: leave it out for Azure DevOps Services. For your own server, give the address of its collections, such ashttps://server/tfs.
The values go in your own secrets (Settings ▸ You ▸ Secrets), never in mcp.json.
The connector finds the repository from the folder's git remote (origin first). A tool or
an event can name another one with repo, as organization/project/name (on a server,
collection/project/name). A project's name can have spaces: acme/Web App/app.
The tools¶
list_pull_requests,get_pull_request(with its description, head commit, reviewers and their votes, and the combined state of its builds), andget_checks(the newest build of each pipeline of a branch or a pull request, and the statuses other services set on a pull request).get_build_log: a failed build's failed steps, their errors and the end of each log.comment_on_pull_request: a comment in a new thread.retry_build: a finished build's failed jobs run again, in the same build.- For the pages:
show_pull_requests,show_pull_requestandshow_pull_request_diff. - For the ready-made workflows:
create_pull_request,list_pull_request_comments(the comments on lines of the diff, with each one'sthreadId) andreply_to_pull_request_comment(an answer in that thread).
Merging and approving are a person's, as on GitHub: merge_pull_request (complete, or
auto-complete) and approve_pull_request (a vote of approved) are only on the copy the host
runs for your own windows and devices, never offered to an agent.
The events¶
The events have the gitlab connector's names, so a workflow made for GitHub or GitLab works here too:
checks.failed: an active pull request's checks failed at its head commit: a build of the pull request, a build of its branch at that commit (a CI trigger), or the newest status that another service set on it.run.idis the first failed build's id, forget_build_log(0 when only a status failed).checks.passed: one of those passed at the head commit, one event per build or status.run.completed: a build of any trigger finished, whatever its result, as the github connector's: for a build no pull request owns, such asmain's or a tag's release, or one started by hand.pipeline(its name),branch(a branch or tag, asmainorv0.16.0) andrun(a build's id) narrow it.run.conclusionis Azure DevOps's result (succeeded,failed,canceled,partiallySucceeded); a build run again is a new event.deploysis what the build says it deployed (see below).deploy.waiting: a build waits for an approver of an environment's Approvals check, as a deployment job toproduction. Each ofenvironmentsis one pending approval, named by the stage it holds;reviewersare its approvers who have not answered, andcanApprovesays whether the token's owner may answer. The next stage it waits on is a new event.pipelineandbranchnarrow it. Answer it on Azure DevOps.pr.opened,pr.merged(completed),pr.closed(abandoned),pr.conflicted.review.requested: for you, the token's owner: you are a reviewer and have not voted.review.comment: a comment on a line of a pull request's diff.comment.threadIdis the thread to answer in.
A build says what it deployed with a warning whose code is deploy and whose message is
the deploy's ref, <target>:<id>/<version>, as GitHub Actions' ::notice title=deploy::
(a build tag cannot hold a colon):
- bash: echo "##vso[task.logissue type=warning;code=deploy]testflight:com.example.app/$(Build.BuildId)"
Unless an event's anyone is true, a bot (a build service) and a pull request from a fork
never count. Azure DevOps lets only a project's members open a pull request or comment on
one, so every other person counts.
See pull requests on the connector's pages¶
An agent shows a page when it calls the tool that feeds it. Ask, for example, "Show the open pull requests on Azure DevOps".
Pull requests (show_pull_requests) lists the 50 newest active pull requests. Each one
has its checks (its builds and other services' statuses), a conflict, its review and
Auto-complete when that is on. A pull request whose build failed has Retry. Click a
title to open its page in the same view.
The list is in sections: Needs you (you are a reviewer who has not voted, or your own pull request has failed checks, a conflict, or a reviewer who rejected it or waits for you), Yours, Team and Others. With a control plane, Team is its people and bots, by their Azure DevOps login (see Your Azure DevOps login), and a row shows the name the control plane knows; the rest are Others. Without one, everyone else in the organization is Team, as an organization has only its own members.
A folder's own repository is on the Work pages, so its sidebar has no row for this list. To keep the page, choose Pin to Folder in the view's menu. See Pin a page to a folder.
Work on a pull request¶
A pull request's page has five tabs: Conversation, Line comments, Files, Checks and Lineage.
- Files: each file and how it changed. Azure DevOps says no counts of lines here. Show Diff, or a file's name, shows the changed lines in the app's own diff.
- Checks: the newest build of each pipeline and the newest status of each other service.
A failed build has Show Log, the end of its failed steps' logs (
get_build_log), and Retry Failed Jobs runs them again (retry_build). Another service's status opens on its own page. - Lineage: the sessions on the pull request, with what they cost (#3952).
Under the tabs is a box for your words, and these buttons. Each one acts on Azure DevOps as you:
- Comment adds the box's words as a comment, in a thread of its own.
- Approve shows only on someone else's pull request: a vote of approved.
- Merge completes it into the target branch (squashes it, when the branch's Limit merge types policy allows squash and not a merge) and deletes the branch. It asks you again first. A draft, or a pull request in conflict, can't be merged.
- Auto-merge shows while its checks run: Azure DevOps's auto-complete, which completes it once its policies pass.
- Ask an Agent sends the work to the agent on the branch: failed checks, a conflict or open line comments, with the box's words. The app asks you before it sends. With no agent on that branch, the new-agent form opens on the branch.
Agent Loops can't merge or approve from this page. Those tools are for a person only. They carry the commit that the page shows. When the pull request has a newer commit, nothing happens: open the page again.
On the Work pages¶
With Azure DevOps connected, Work ▸ Pull requests lists the pull requests of each folder
whose remote is on Azure DevOps (dev.azure.com, *.visualstudio.com, or the connected Azure
DevOps Server), beside the other forges', the last opened or closed first. The repository,
organization/project/repo, is a choice in the Repo filter. Without a token for that Azure
DevOps (the connection, or the connector's AZURE_DEVOPS_TOKEN and AZURE_DEVOPS_URL), the
list says Azure DevOps is not connected. Work ▸ Issues lists Azure Boards work items, not
this connector's: see Use Azure Boards work items.
A pull request's page has its description and comments, its checks (the newest Azure Pipelines build of each pipeline of the pull request, and the newest status of each other service), Open on Azure DevOps, and:
- Merge: merge, squash or rebase, as the target branch's Limit merge types policy allows them (all three with no policy), and Merge when checks pass, which is Azure DevOps's auto-complete. Either deletes the branch.
- Approve: a vote of approved, at the head commit the page shows.
- Rerun failed: each failed Azure Pipelines build runs its failed jobs again. A check's log is the end of its build's failed steps. Another service's status runs again on its own page.
- Show Diff: each file's changes against the merge base with the target. Azure DevOps says which lines changed, and the page reads the lines of both commits, so a diff of more than 100 files lists the rest with no lines.
- Labels: the pull request's tags. Azure DevOps has no list of a repository's tags, so the menu offers the tags of its 100 newest pull requests.
- Close: abandons the pull request; Reopen makes it active again.
- A comment box: a comment is a thread of its own.
What to know¶
- The Pull requests page reads each pull request's builds and statuses. Azure DevOps has no list of many pull requests' builds, so the page reads four pull requests at a time.
- Comments are read for the 50 newest active pull requests, and those closed since the last poll. Azure DevOps has no list of a repository's comments.
- Checks are builds and statuses. Statuses are read for the 50 newest active pull
requests, the newest of each context, at the pull request's newest push. A build of a branch
that no active pull request is from (
main, a tag) raises no event. - The Work pages read Azure DevOps on each machine. The list asks each repository, a state at a time, as Azure DevOps has no list across repositories; it filters a tag and words itself, as Azure DevOps cannot. A pull request has no time of its last change, so the list is in the order each was opened or closed. An assignee lists none: a pull request has reviewers, not assignees.
- The Work pages read one Azure DevOps on a machine: the first folder's, with a token for it. A folder on another lists nothing, and says so when none is read.
- Lineage links Azure Repos pull requests (#3952). A session's
P#12label in a folder on Azure DevOps works on pull request 12, and its#12label on work item 12 of the repository's project on Azure Boards, as Azure DevOps reads#12in a description. A pull request's events link it to the sessions on its branch and to the work items its description closes, and a failed Azure Pipelines build builds it (azuredevops:<org>/<project>/<repo>/builds/<id>). An Azure Boards work item's Lineage section lists the pull requests that fix it. - Lineage asks Azure DevOps with the Azure DevOps connection or
AZURE_DEVOPS_TOKEN, about the repositories of the folders on it: a pull request's title, state (an abandoned one is closed) and tags, a version tag's pull requests (fromMerged PR 12:at the start of a merge or squash commit's title, or else the pull request whose merge commit it is), and the cost comment on a merged pull request (when the folder'sprCostCommentsays so), in a closed thread of its own, so a policy that wants comments resolved is not held by it. Azure Repos has no milestones. A doc's address is?path=/<path>, on the default branch. - On an Azure DevOps Server (#4107), lineage reads a pull request's address by the
connected Server's root (the connection's, else
AZURE_DEVOPS_URL), so a path such as/tfs/is left out before the collection, and a repository named as its project (collection/_git/name) is linked. The addresses a Lineage section gives keep that path. A Server that is not connected has its collection read two parts before_git.