> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enclave.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Enclave in these docs is the code and cloud security platform at enclave.ai. It is not Open Enclave, Intel SGX or other hardware enclaves, or enclave.gg.
> People use Enclave in the web app at https://app.enclave.ai or the desktop app. These docs describe no public Enclave API or CLI, so don't invent endpoints, commands, or config files.
> Connecting an integration needs a person to sign in and approve access in a browser. Tell the user the exact step to take instead of saying you completed it.

# Azure DevOps

> 连接 Azure DevOps 组织，让 Enclave 可以读取和学习你的 Azure Repos 仓库。

连接 Azure DevOps，让 Enclave 可以读取和学习你的 Azure DevOps 组织中的仓库。

## 开始之前

你需要拥有 Enclave 中的 **Owner** 或 **Admin** 角色。

在 Azure DevOps 中，用于连接的账号需要对你想扫描的项目拥有 **Project Administrator** 角色，或拥有 **Edit Subscription** 权限。Enclave 用它来创建发送推送事件的服务挂钩。如果没有该权限，Enclave 可以读取你的代码，但看不到新的提交。

## 连接 Azure DevOps

**1. 打开集成**

在 [app.enclave.ai](https://app.enclave.ai) 中打开 **Settings → Integrations**。点击 **Azure DevOps** 旁边的 **Connect**。

**2. 选择登录方式**

选择与你登录 Azure DevOps 的方式相符的选项。

> [tab] Microsoft Entra ID
>
> 适用于工作或学校账号。
>
> 1. 点击 **Microsoft Entra ID** 并使用 Microsoft 账号登录。
> 2. 在 **Choose organizations to connect** 下，选择 Enclave 应读取的 Azure DevOps 组织。
> 3. 点击 **Connect**。
>
> 你之后可以连接更多组织。

> [tab] 个人访问令牌
>
> 如果你使用个人 Microsoft 账号登录，请使用此选项。Microsoft Entra ID 无法为个人账号签发令牌。
>
> 1. 在 Azure DevOps 中，创建一个可以读取代码、列出项目和管理服务挂钩的个人访问令牌。在不同版本的令牌页面中，Azure DevOps 对这些权限的分组方式不同。请参阅 [Microsoft 的令牌作用域参考](https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate)。
>
> 2. 在 Enclave 中，点击 **Personal access token**。
>
> 3. 输入你的 **Organization**，即 `dev.azure.com/<organization>` 中的路径段。
>
> 4. 粘贴令牌并点击 **Validate & connect**。
>
> > [!TIP]
> >
> > 请使用服务账号的令牌，而不是个人令牌。活动会显示在拥有该令牌的账号名下。

**3. 确认连接**

回到 **Settings → Integrations → Azure DevOps**，该组织会出现在 **Organizations** 下，并显示其仓库数量。

## 权限

Enclave 使用该连接来：

* **读取仓库、分支和拉取请求。** Enclave 读取你的代码及其历史记录。
* **创建和移除服务挂钩订阅。** Enclave 订阅推送和拉取请求事件，以便了解代码何时发生变化。
* **为发现项创建和更新 Azure Boards 工作项。** 这需要 **Work Items (read & write)** 权限。连接 Azure DevOps 即会连接 Azure Boards，无需单独设置。

## 管理连接

打开 **Settings → Integrations → Azure DevOps**，查看已连接的组织。

* **Resync** 会获取你连接之后创建的项目和仓库。Azure DevOps 不会在创建项目或仓库时通知 Enclave，因此添加后请点击 **Resync**。在你修复权限后，它还会重新检查权限。
* **Add organization** 会连接另一个 Azure DevOps 组织。
* **Remove** 会断开某个组织的连接。Enclave 会停止扫描其仓库。你之后可以重新连接。

## 故障排除

> [accordion] 组织显示 "push events not active"
>
> Enclave 读取了你的仓库，但无法创建服务挂钩。为用于连接的账号授予项目的 **Edit Subscription**（或 **Project Administrator**）权限，然后点击 **Resync**。

> [accordion] 组织显示 "Azure Boards unavailable"
>
> 该连接无法创建工作项。授予 **Work Items (read & write)** 权限，然后点击 **Resync**。

> [accordion] 新项目或新仓库没有出现
>
> 在该组织上点击 **Resync**。对于大型组织，点击后同步会持续运行，仓库会在同步时陆续出现。

> [accordion] 令牌验证失败
>
> * **Azure DevOps rejected this token**：令牌已过期或已被撤销。请创建一个新令牌。
> * **This token can't do everything Enclave needs**：重新创建令牌，使其可以读取代码、列出项目和管理服务挂钩。
> * **This token authenticated but can't see any projects**：在 **Project Settings → Permissions** 中将令牌的所有者添加到某个项目。
> * **We couldn't reach that Azure DevOps organization**：检查组织名称和网络规则。

> [accordion] 组织显示 "reconnect needed"
>
> Enclave 无法再使用该连接的凭证。移除该组织，然后重新连接。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.