You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否在VSTS的Artifacts中添加Latest-1构建?需构建VSO发布工作流做兼容检查

Can I Add the Latest-1 Build as an Artifact in VSTS?

Absolutely! You can absolutely add the Latest-1 build as an artifact in your Azure DevOps (formerly VSTS/VSO) release pipeline—this is a common pattern for backward compatibility testing, and it’s totally supported. Here’s how to set it up smoothly:

Start by adding a second build artifact to your release pipeline:

  1. Open your release pipeline and navigate to the Artifacts section.
  2. Click Add, select Build as the source, and choose your target build pipeline.
  3. For the version selection:
    • If you just need a one-off test, you can manually pick the specific Latest-1 build version from the dropdown.
    • For an automated, ongoing workflow (the better choice), use a dynamic approach to fetch the Previous build ID automatically.

Option 2: Dynamically Fetch Latest-1 Build ID via Script

To make this fully automated (so you don’t have to manually update the version every time), use a PowerShell task to pull the Latest-1 build ID via the Azure DevOps REST API:

  1. Add a PowerShell task early in your release pipeline (before any tasks that need the Previous build artifact).
  2. Use this sample script (replace YOUR_BUILD_DEFINITION_ID with your actual build pipeline ID):
    $orgUri = "$(System.TeamFoundationCollectionUri)"
    $projName = "$(System.TeamProject)"
    $buildDefId = "YOUR_BUILD_DEFINITION_ID"
    $apiVersion = "7.1-preview.7"
    
    $headers = @{
        Authorization = "Bearer $(System.AccessToken)"
    }
    
    # Fetch the last 2 completed builds from your pipeline
    $url = "$orgUri/$projName/_apis/build/builds?definitions=$buildDefId&`$top=2&api-version=$apiVersion&statusFilter=completed"
    $response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
    
    # The first result is the Latest build, the second is Latest-1
    $previousBuildId = $response.value[1].id
    
    # Set a pipeline variable to use for the artifact version
    Write-Host "##vso[task.setvariable variable=PreviousBuildId;]$previousBuildId"
    
  3. Go back to your second build artifact’s settings, select Specific version, and enter $(PreviousBuildId). Now every release will automatically pull the Latest-1 build.

Key Notes to Keep in Mind

  • Permissions: Make sure the service account running your release pipeline has Build (Read) permissions on your target build pipeline—this is required to fetch build details via the API.
  • Retention Policies: Double-check your build retention settings to ensure Latest-1 builds aren’t deleted before your release runs.
  • Artifact Paths: You can reference both artifacts in your tasks using their respective paths (e.g., $(System.DefaultWorkingDirectory)/_MyBuildPipeline/Latest and $(System.DefaultWorkingDirectory)/_MyBuildPipeline/PreviousBuild—adjust the labels to match how you named your artifacts).

Once everything’s set up, you can run your backward compatibility tests against both the latest and previous build artifacts seamlessly in your release workflow.

内容的提问来源于stack exchange,提问作者Rajasekhar Somanchi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:20:20