共用方式為


快速入門:開始使用 Azure DevOps CLI

Azure DevOps 服務

本快速入門示範如何安裝並開始使用 Azure 命令列介面 (CLI) 的 Azure DevOps 延伸模組。 延伸模組會新增命令,以從命令列管理 Azure DevOps Services,讓您可以編寫腳本並自動化一般工作。

您將學到什麼:

  • 如何為 Azure CLI 安裝 Azure DevOps 擴充功能
  • 如何登入、設定預設值,以及取得指令的幫助
  • 如何使用 CLI 在瀏覽器中開啟 Azure DevOps 項目

快速步驟:

  1. 安裝 Azure CLI(如果還沒安裝)
  2. 新增或更新 Azure DevOps 擴充功能
  3. 登入並設定預設組織/專案
  4. 使用 az devops --help 或開啟物品時使用 --open

注意

Azure DevOps CLI 延伸模組僅適用於 Azure DevOps Services (雲端) 。 它不支援 Azure DevOps Server (內部部署) 。

安裝和更新

  1. 安裝 Azure CLI。 請遵循 安裝 Azure CLI 中的步驟。 安裝後,請驗證您的版本:
az --version
  1. 新增 Azure DevOps 擴充功能。

    az extension add --name azure-devops
    

    如果您已經安裝了擴展,並且想要確定您擁有最新版本,請運行更新命令:

    az extension update --name azure-devops
    
  2. 若要確認安裝,請執行 命令 az extension listaz extension show --name azure-devops

  3. 若要登入,請執行 az login 命令。 Azure CLI 僅支援使用使用者名稱和密碼搭配 az login的互動式登入。 若要使用個人存取令牌登入(PAT),請參閱 透過 Azure DevOps PAT 登入

    注意

    Azure DevOps CLI 擴充目前支援互動式認證與 PAT 認證。 對於服務主體與受管理身份,直接使用 REST API 或用戶端函式庫。

  4. 建議您為組織和項目設定預設組態。 否則,您可以在個別命令本身中指定值。

    az devops configure --defaults organization=https://dev.azure.com/contoso project=ContosoWebApp
    

啟用 Azure DevOps 的 AI 協助

若要提高 Azure DevOps 工作流程的生產力,請使用 Azure DevOps MCP 伺服器來啟用專案數據的 AI 協助。 取得每日站立會議、衝刺規劃、程式碼檢閱、專案報告、提取要求分析和工作專案管理的智慧深入解析,所有這些都透過對 AI 助理的自然語言查詢。 如需詳細資訊和安裝指示,請參閱 Azure DevOps MCP 伺服器概觀

使用命令

新增 Azure DevOps 擴充功能會新增 devopspipelinesartifactsboardsrepos 群組。

針對任何命令的使用方式和說明內容,請指定 --help 參數,例如:

az devops --help
Group
    az devops : Manage Azure DevOps organization level operations.
        Related Groups
        az pipelines: Manage Azure Pipelines
        az boards: Manage Azure Boards
        az repos: Manage Azure Repos
        az artifacts: Manage Azure Artifacts.
   
Subgroups:
    admin            : Manage administration operations.
    extension        : Manage extensions.
    project          : Manage team projects.
    security         : Manage security related operations.
    service-endpoint : Manage service endpoints/service connections.
    team             : Manage teams.
    user             : Manage users.
    wiki             : Manage wikis.

Commands:
    configure        : Configure the Azure DevOps CLI or view your configuration.
    feedback         : Displays information on how to provide feedback to the Azure DevOps CLI team.
    invoke           : This command will invoke request for any DevOps area and resource. Please use
                       only json output as the response of this command is not fixed. Helpful docs -
                       https://learn.microsoft.com/rest/api/azure/devops/.
    login            : Set the credential (PAT) to use for a particular organization.
    logout           : Clear the credential for all or a particular organization.

在瀏覽器中開啟專案

您可以使用 --open 參數,在預設瀏覽器中開啟 Azure DevOps 入口網站中的任何成品。

az pipelines build show --id 1 --open

此命令會在 [命令提示字元] 視窗中顯示組建 --id 1 的詳細數據,並在預設瀏覽器中開啟它。