開始使用 Azure DevOps CLI

Azure DevOps Services

透過適用于 Azure 命令列介面的 Azure DevOps 擴充功能 (CLI) ,您可以從命令列管理許多Azure DevOps Services。 CLI 命令可讓您使用更快速且彈性的互動式畫布簡化工作,略過使用者介面工作流程。

注意

Azure DevOps 命令列介面 (CLI) 僅適用于Azure DevOps Services。 Azure CLI 的 Azure DevOps 擴充功能不支援任何版本的 Azure DevOps Server。

若要開始使用適用于 Azure CLI 的 Azure DevOps 擴充功能,請執行下列步驟:

  1. 安裝 Azure CLI:遵循 安裝 Azure CLI 中提供的指示來設定 Azure CLI 環境。 您的 Azure CLI 版本至少必須是 2.10.1。 您可以使用 az --version 來驗證。

  2. 新增 Azure DevOps 擴充功能:

     az extension add --name azure-devops
    

    您可以使用 az extension listaz extension show --name azure-devops 來確認安裝。

  3. 登入:執行 az login 以登入。 請注意,我們僅支援使用使用者名稱和密碼搭配 az login 的互動式或登入。 若要使用個人存取權杖 (PAT) 登入,請參閱 透過 Azure DevOps Personal Access Token 登入 (PAT)

  4. 設定預設值:建議您為組織和專案設定預設組態。 否則,您可以在個別命令本身內設定這些專案。

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

命令使用方式

新增 Azure DevOps 擴充功能會新增 devopspipelinesartifactsboardsrepos 群組。 針對任何命令的使用方式和說明內容,輸入 -h 參數,例如:

az devops -h
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 置的詳細資料,也會在預設瀏覽器中開啟它。