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

如何在VSTS中仅当工件变更时触发夜间部署并避免重复发布

Perfect question—let’s walk through exactly how to set this up in Azure DevOps (previously VSTS) to hit all your requirements: nightly scheduled deployments that only run when artifacts have changed since the last release, plus blocking duplicate deployments of the same version no matter if they’re triggered manually or on schedule.

Step 1: Configure Your Nightly Schedule to Only Trigger on Artifact Changes

First, let’s make sure that nightly schedule doesn’t waste time running when nothing has changed:

  • Open your release definition, go to the Triggers tab (the schedule icon you mentioned in the artifacts area links directly here).
  • Edit your existing nightly scheduled trigger.
  • Look for the Artifacts section in the trigger settings, then check the box labeled "Only trigger a release if the artifact has changed since the last successful release".
    • This tells Azure DevOps to skip the nightly run entirely if none of your linked artifacts (builds, packages, etc.) have new versions since the last time the release completed successfully.
Step 2: Block Duplicate Deployments with Pre-Deployment Conditions

Even with the trigger locked down, someone might accidentally manually trigger a release using an already-deployed artifact version. Let’s add a safety net here:

  • Go to your target deployment stage (like "Production") and click the Pre-deployment conditions icon (the little lightning bolt next to the stage name).
  • Scroll down to the Deployment conditions section, then enable the option "Skip deployment if the same artifact version was already successfully deployed to this stage".
    • This will automatically abort the deployment if the exact artifact version you’re trying to push has already been successfully deployed to this stage before—whether it’s a manual trigger or a scheduled one.
Step 3: Optional: Custom Conditions for Granular Control

If you need more precision (like checking only specific artifacts instead of all), you can use custom variables and conditions:

  • First, create a variable in your release’s Variables tab to track the last successful artifact version (you can populate this with a post-deployment script that saves the current version to a variable group, or use the built-in Release.Artifacts.{YourArtifactAlias}.SourceVersion variable).
  • Then, in the pre-deployment conditions, add a custom condition like:
    ne(variables['Release.Artifacts.MyAppArtifact.SourceVersion'], variables['LastSuccessfulDeployedVersion'])
    
    • Swap MyAppArtifact with your artifact’s alias, and LastSuccessfulDeployedVersion with your tracking variable. This ensures deployment only proceeds if the current artifact version is different from the last successful one.
Quick Test to Validate Your Setup

To make sure everything works:

  • Try manually triggering a release with an artifact version that’s already been deployed—you’ll see the stage skip automatically.
  • Let the nightly schedule run when no artifacts have changed—no release will be created.
  • Push a new build or package to your artifact source, and the nightly schedule should kick off a release as expected.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.21 04:29:06