mcpField
S
sprint-254-features

sprint-254-features

github.com/josiahsiegel云与 DevOps59153 次安装19 周前更新
代码仓库

关于 sprint-254-features

这是一份介绍 Azure DevOps 更新的参考技能,涵盖流水线阶段、托管映像、安全、GitHub 集成和 Agent 能力,面向维护流水线及相关工作流的人员。

主要功能

  1. 01流水线表达式与阶段变量
  2. 02阶段依赖关系可视化
  3. 03托管映像变更与迁移
  4. 04GitHub 工作项与 PR 链接
  5. 05安全与身份验证更新
  6. 06Azure Pipelines Agent v4 信息

适用场景

  1. 01将 YAML 流水线更新为新版映像
  2. 02检查阶段依赖关系
  3. 03规划从 OAuth 迁移到 Entra ID
  4. 04通过工作项使用 GitHub Copilot

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/josiahsiegel/claude-plugin-marketplace --skill sprint-254-features

安装后在 Claude Code 中输入/sprint-254-features确认已加载。

详细介绍

🚨 关键指南

Windows 文件路径要求

强制要求:在 Windows 上始终使用反斜杠表示文件路径

在 Windows 上使用 Edit 或 Write 工具时,文件路径必须使用反斜杠(\),而不是正斜杠(/)。

示例:

  • ❌ 错误:D:/repos/project/file.tsx
  • ✅ 正确:D:\repos\project\file.tsx

适用于:

  • Edit 工具的 file_path 参数
  • Write 工具的 file_path 参数
  • Windows 系统上的所有文件操作
文档指南

除非用户明确要求,否则绝不创建新的文档文件。

  • 优先事项:更新现有的 README.md 文件,而不是创建新文档
  • 保持仓库整洁:保持仓库根目录整洁——除非用户另有要求,否则仅保留 README.md
  • 风格:文档应简洁、直接、专业,避免 AI 生成的语气
  • 用户偏好:仅在用户明确要求提供文档时,才创建其他 .md 文件

Azure DevOps 2025 最新功能(Sprint 254-262)

新增表达式函数(Sprint 248)

iif() - 三元条件运算符
# Syntax: iif(condition, valueIfTrue, valueIfFalse)

variables:
  environment: 'production'
  # Use iif for conditional values
  instanceCount: ${{ iif(eq(variables.environment, 'production'), 10, 2) }}
  deploymentSlot: ${{ iif(eq(variables.environment, 'production'), 'production', 'staging') }}

steps:
- script: echo "Deploying ${{ variables.instanceCount }} instances to ${{ variables.deploymentSlot }}"
trim() - 移除空白字符
parameters:
- name: branchName
  type: string
  default: ' feature/my-branch '

variables:
  # Remove leading/trailing whitespace
  cleanBranch: ${{ trim(parameters.branchName) }}
  # Result: 'feature/my-branch' (no spaces)

新增预定义变量(Sprint 253)

Build.StageRequestedBy

请求执行阶段的人员:

stages:
- stage: Deploy
  jobs:
  - job: DeployJob
    steps:
    - script: |
        echo "Stage requested by: $(Build.StageRequestedBy)"
        echo "Stage requester ID: $(Build.StageRequestedById)"
      displayName: 'Log stage requester'

    # Use for approval notifications
    - task: SendEmail@1
      inputs:
        to: '[email protected]'
        subject: 'Deployment requested by $(Build.StageRequestedBy)'

阶段依赖关系可视化(Sprint 254)

在管道 UI 中展开阶段时查看阶段依赖关系:

stages:
- stage: Build
  jobs:
  - job: BuildJob
    steps:
    - script: echo "Building..."

- stage: Test
  dependsOn: Build  # Shown visually when expanded
  jobs:
  - job: TestJob
    steps:
    - script: echo "Testing..."

- stage: Deploy_USEast
  dependsOn: Test
  jobs:
  - job: DeployJob
    steps:
    - script: echo "Deploying to US East..."

- stage: Deploy_EUWest
  dependsOn: Test  # Parallel with Deploy_USEast - visualized clearly
  jobs:
  - job: DeployJob
    steps:
    - script: echo "Deploying to EU West..."

优点:

  • 在 UI 中查看可视化依赖关系图
  • 更轻松地调试复杂管道
  • 清晰呈现多区域部署模式
  • 识别并行阶段与顺序阶段

新增操作系统映像

Ubuntu-24.04(正式发布)
pool:
  vmImage: 'ubuntu-24.04'  # Latest LTS - Recommended
  # OR use ubuntu-latest (will map to 24.04 soon)
  # vmImage: 'ubuntu-latest'

steps:
- script: |
    lsb_release -a
    # Ubuntu 24.04 LTS (Noble Numbat)

关键信息:

  • Ubuntu 24.04 现已正式发布
  • ubuntu-latest 即将映射到 ubuntu-24.04(目前映射到 ubuntu-22.04)
  • Ubuntu 20.04 已于 2025 年 4 月 30 日彻底移除
Windows Server 2025(将于 2025 年 6 月推出)
pool:
  vmImage: 'windows-2025'  # GA: June 16, 2025

steps:
- pwsh: |
    Get-ComputerInfo | Select-Object WindowsProductName, WindowsVersion

关键信息:

  • 正式发布:2025 年 6 月 16 日
  • 从 2025 年 9 月 2 日起,windows-latest 将映射到 windows-2025
  • Windows Server 2019 的扩展支持将持续到 2025 年 12 月 31 日
macOS-15 Sequoia(现已推出)
pool:
  vmImage: 'macOS-15'  # Sequoia

steps:
- script: |
    sw_vers
    # macOS 15.x (Sequoia)

关键信息:

  • macOS 13 Ventura 将于 2025 年 9 月 1 日开始弃用
  • 计划于 2025 年 12 月 4 日停止支持 macOS 13
  • Apple Silicon(ARM64)支持处于预览阶段
⚠️ 已弃用和已停用的映像

已彻底移除(2025 年):

  • Ubuntu 20.04 - 于 2025 年 4 月 30 日移除
  • .NET 6 - 于 2025 年 8 月 1 日从 Windows 和 Ubuntu 映像中移除

扩展支持:

  • Windows Server 2019 - 扩展支持至 2025 年 12 月 31 日
    • 开始弃用:2025 年 6 月 1 日
    • 停机时段:2025 年 6 月 3-24 日
    • 最终移除:2025 年 12 月 31 日

即将弃用:

  • macOS 13 Ventura - 弃用时间:2025 年 9 月 1 日;停用时间:2025 年 12 月 4 日

迁移建议:

# Ubuntu Migration
# OLD (Removed)
pool:
  vmImage: 'ubuntu-20.04'

# NEW (Recommended)
pool:
  vmImage: 'ubuntu-24.04'  # Best: explicit version
  # OR
  vmImage: 'ubuntu-latest'  # Will map to 24.04 soon

# Windows Migration
# OLD (Being deprecated)
pool:
  vmImage: 'windows-2019'

# NEW (Recommended)
pool:
  vmImage: 'windows-2022'  # Current stable
  # OR wait for
  vmImage: 'windows-2025'  # GA June 2025

GitHub 集成改进

自动关联拉取请求

与工作项关联的 GitHub 分支会自动关联拉取请求:

# When PR is created for branch linked to work item,
# PR automatically appears in work item's Development section

trigger:
  branches:
    include:
    - feature/*
    - users/*

# Work item auto-linking based on branch name pattern
# AB#12345 in commits auto-links to work item 12345
“已集成到构建中”链接

GitHub 仓库会显示集成该拉取请求的构建:

pr:
  branches:
    include:
    - main
    - develop

# After PR merged, work item shows:
# "Integrated in build: Pipeline Name #123"
# Direct link to build that deployed the change

阶段级变量

stages:
- stage: Build
  variables:
    buildConfiguration: 'Release'
    platform: 'x64'
  jobs:
  - job: BuildJob
    steps:
    - script: echo "Building $(buildConfiguration) $(platform)"

- stage: Deploy
  variables:
    environment: 'production'
    region: 'eastus'
  jobs:
  - job: DeployJob
    steps:
    - script: |
        echo "Stage: $(System.StageName)"
        echo "Requested by: $(Build.StageRequestedBy)"
        echo "Deploying to $(environment) in $(region)"

实用示例

使用新功能进行多区域部署
parameters:
- name: deployToProd
  type: boolean
  default: false

variables:
  # Use iif for conditional values
  targetEnvironment: ${{ iif(parameters.deployToProd, 'production', 'staging') }}

stages:
- stage: Build
  jobs:
  - job: BuildApp
    pool:
      vmImage: 'ubuntu-24.04'  # New image
    steps:
    - script: npm run build

- stage: Test
  dependsOn: Build
  jobs:
  - job: RunTests
    pool:
      vmImage: 'ubuntu-24.04'
    steps:
    - script: npm test

- stage: Deploy_USEast
  dependsOn: Test
  condition: succeeded()
  variables:
    region: 'eastus'
  jobs:
  - deployment: DeployToUSEast
    environment: ${{ variables.targetEnvironment }}
    pool:
      vmImage: 'ubuntu-24.04'
    strategy:
      runOnce:
        deploy:
          steps:
          - script: |
              echo "Deploying to $(region)"
              echo "Requested by: $(Build.StageRequestedBy)"

- stage: Deploy_EUWest
  dependsOn: Test  # Parallel with Deploy_USEast
  condition: succeeded()
  variables:
    region: 'westeurope'
  jobs:
  - deployment: DeployToEUWest
    environment: ${{ variables.targetEnvironment }}
    pool:
      vmImage: 'ubuntu-24.04'
    strategy:
      runOnce:
        deploy:
          steps:
          - script: |
              echo "Deploying to $(region)"
              echo "Requested by: $(Build.StageRequestedBy)"

# Stage dependencies visualized clearly in UI (Sprint 254)

持续访问评估(Sprint 260 - 2025 年 8 月)

通过 CAE 增强安全性

Azure DevOps 现已支持持续访问评估(CAE),可通过 Microsoft Entra ID 近乎实时地强制执行条件访问策略。

主要优势:

  • 发生关键事件时立即撤销访问权限
  • 无需等待令牌过期
  • 提升安全态势

触发访问权限撤销的情形:

  • 用户帐户已禁用
  • 密码已重置
  • 位置或 IP 地址发生变化
  • 检测到风险事件
  • 违反策略

示例场景:

# Your pipeline with CAE enabled automatically
stages:
  - stage: Production
    jobs:
      - deployment: Deploy
        environment: 'production'
        pool:
          vmImage: 'ubuntu-24.04'
        strategy:
          runOnce:
            deploy:
              steps:
                - script: echo "Deploying..."
                  # If user credentials are revoked mid-deployment,
                  # CAE will instantly terminate access

实施:

  • 正式发布:2025 年 8 月
  • 分阶段向所有客户推出
  • 无需配置(所有 Azure DevOps 组织均自动启用)
  • 可与 Microsoft Entra ID 条件访问策略配合使用

安全性改进:

  • 立即响应安全事件
  • 将攻击窗口从数小时或数天缩短至数秒
  • 补充现有安全功能(Key Vault、分支策略等)

OAuth 应用弃用(2025 年 4 月)

重要变更:

  • Azure DevOps 不再支持新注册 Azure DevOps OAuth 应用(自 2025 年 4 月起生效)
  • 这是逐步停用 Azure DevOps OAuth 平台的第一步
  • 现有 OAuth 应用仍可继续使用
  • 规划迁移到 Microsoft Entra ID 身份验证

迁移建议:

# Use service connections with Microsoft Entra ID instead
- task: AzureCLI@2
  inputs:
    azureSubscription: 'service-connection'  # Uses Managed Identity or Service Principal
    scriptType: 'bash'
    scriptLocation: 'inlineScript'
    addSpnToEnvironment: true
    inlineScript: |
      az account show

SNI 要求(2025 年 4 月)

网络要求:

  • 所有传入的 HTTPS 连接都必须使用服务器名称指示(SNI)
  • 生效日期:2025 年 4 月 23 日
  • 影响所有 Azure DevOps Services 连接

检查事项:

  • 确保客户端支持 SNI(大多数现代客户端都支持)
  • 根据需要更新旧版工具或脚本
  • 在 2025 年 4 月 23 日前测试连接

OAuth 应用弃用(Sprint 261 - 2025 年 9 月)

重要安全变更:

Azure DevOps 将限制 OAuth 客户端密钥仅显示一次:

  • 新生成的客户端密钥仅在创建时显示一次
  • Get Registration Secret API 将停用
  • 生效日期:2025 年 9 月 2 日
  • 不再允许注册新的 OAuth 应用

迁移路径:

# Replace OAuth apps with Microsoft Entra ID authentication
# Use service connections with Managed Identity or Service Principal
- task: AzureCLI@2
  inputs:
    azureSubscription: 'entra-id-service-connection'
    scriptType: 'bash'
    addSpnToEnvironment: true
    inlineScript: |
      az account show
      # Authenticated via Entra ID

所需操作:

  • 审核现有 OAuth 应用
  • 规划迁移到 Entra ID 身份验证
  • 更新 CI/CD 管道,以使用服务连接
  • 记录密钥轮换流程

Agent 软件版本 4(2024 年 10 月至今)

重大升级:

Azure Pipelines Agent 已从 v3.x 升级到 v4.x,并由 .NET 8 提供支持:

主要改进:

  • 基于 .NET 8 构建,性能和安全性更佳
  • 扩展平台支持,包括 ARM64
  • 改进可靠性和诊断功能
  • 更出色的资源管理

平台支持:

  • Linux: Debian 11 和 12、Ubuntu 24.04、22.04、20.04(支持 ARM64)
  • macOS: Intel 和 Apple Silicon(支持 ARM64)
  • Windows: Windows Server 2019、2022、2025

ARM64 支持:

# Self-hosted ARM64 agent
pool:
  name: 'arm64-pool'
  demands:
    - agent.os -equals Linux
    - Agent.OSArchitecture -equals ARM64

steps:
  - script: uname -m
    displayName: 'Verify ARM64 architecture'

注意: ARM64 支持适用于自托管 Agent。Microsoft 托管的 ARM64 macOS Agent 目前处于预览阶段。

Sprint 262 - GitHub Copilot 集成(2025 年)

AI 驱动的工作项辅助功能(私人预览):

将 Azure Boards 工作项直接连接到 GitHub Copilot:

功能:

  • 将工作项发送给 Copilot 编码 Agent
  • AI 辅助修复 Bug
  • 自动实现功能
  • 改进测试覆盖率
  • 更新文档
  • 减少技术债务

使用流程:

  1. 在 Azure Boards 中创建工作项
  2. 在说明中添加详细需求
  3. 发送给 GitHub Copilot
  4. Copilot 生成代码更改
  5. 通过标准 PR 流程进行审核和合并

与 Pipelines 集成:

# Work items auto-link with PRs
trigger:
  branches:
    include:
    - feature/*

# Mention work item in commit
# Example: "Fix login bug AB#12345"
# Automatically links PR to work item and tracks in build

资源

评论

支持 Markdown