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

如何配置O365PostMessageBuild任务使其仅在计划触发流水线时执行?

Solution to Run O365PostMessageBuild Only on Scheduled Pipeline Triggers

Got it! To ensure your O365PostMessageBuild@0 task executes only when the pipeline is triggered by your scheduled cron job, you'll need to adjust the task's condition to check against Azure DevOps' built-in pipeline variable.

Step-by-Step Adjustment

Azure DevOps sets the Build.Reason predefined variable based on how the pipeline was triggered. For scheduled runs, this variable's value is Schedule.

You'll want to combine this check with your existing succeededOrFailed() condition (so the notification sends whether the run passed or failed, but only for scheduled triggers). Here's the updated task configuration:

- task: O365PostMessageBuild@0
  condition: and(succeededOrFailed(), eq(variables['Build.Reason'], 'Schedule'))
  inputs:
    addressType: 'url'
    url: 'https://webhook.office.com/webhookb2/9615602a-d293-4469-ba56'
    messageType: 'message'
    title: 'Test Result'
    summary: 'Scheduled nightly test run'
    text: 'Branch : main'
    includeLink: true
    linkText: 'View last run'

Why This Works

  • eq(variables['Build.Reason'], 'Schedule') ensures the task only runs when the pipeline is triggered by your cron schedule (like your daily midnight build on the main branch).
  • Keeping succeededOrFailed() means the notification will still send regardless of whether the pipeline run succeeded or failed—just like your original setup, but restricted to scheduled triggers.

This change won't affect any other pipeline triggers (like manual runs, PR builds, or CI triggers on code pushes)—the notification task will skip those entirely.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.30 08:27:28