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

如何结合现有CI YAML与Dependabot YAML并实现每周扫描?

Dependabot v2 实现每周一次扫描的配置方案

完全可以实现每周仅运行一次Dependabot扫描的需求,核心是给你的dependabot-pipelines.yml添加定时触发器,同时保留原有的trigger: none避免PR/分支推送触发,结合dependabot.yml的调度配置即可达成目标。

具体配置调整

1. 更新 dependabot-pipelines.yml 添加定时触发

在原文件中加入schedules节点,指定每周的运行时间(和dependabot.yml的调度时间匹配):

#inputs options: https://github.com/tinglesoftware/dependabot-azure-devops/blob/main/extension/README.md
trigger: none
# 添加定时触发器,使用UTC时间,需与目标时区换算
schedules:
  - cron: "0 17 * * 0" # 对应洛杉矶时间周日09:00(夏令时UTC-8),冬令时需改为"0 16 * * 0"
    displayName: 每周日运行Dependabot扫描
    branches:
      include:
        - dev # 和dependabot.yml的target-branch保持一致
    always: true # 即使无代码变更也执行扫描
stages:
  - stage: CheckDependencies
    displayName: 检查依赖更新
    jobs:
      - job: Dependabot
        displayName: 运行Dependabot
        pool:
          vmImage: ubuntu-latest
        steps:
          - task: dependabot@2
            displayName: 执行Dependabot扫描
            inputs:
              setAutoComplete: true

2. 保留 dependabot.yml 现有调度配置

你当前的dependabot.yml已经正确设置了每周扫描的时间规则,这个配置会指导Dependabot在运行时按照指定周期检查更新,仅建议修正标签名称以匹配生态:

version: 2
updates:
  - package-ecosystem: 'nuget'
    directory: '/'
    target-branch: 'dev'
    open-pull-requests-limit: 15
    ignore:
        - dependency-name: 'Microsoft.Extensions.Caching.SqlServer'
    registries:
      - azure_artifacts
    schedule:
      interval: weekly
      day: "sunday"
      time: "09:00"
      timezone: "America/Los_Angeles"    
    labels:
      - "nuget dependencies" # 原标签为"npm dependencies",修正为匹配nuget生态
registries:
  azure_artifacts:
    type: "nuget-feed"
    url: "https://xxx.pkgs.visualstudio.com/0497dd12-e7ca-49f7-999e-7f22d25e38c8/_packaging/TTCWebFeed/nuget/v3/index.json"
    token: "PAT:<PAT>"

关键配置说明

  • trigger: none:确保Dependabot Pipeline仅由定时任务触发,不会被PR提交、分支推送等CI事件干扰。
  • schedules.cron:Azure Pipelines使用UTC时间,需根据你的目标时区(America/Los_Angeles)换算对应时间,夏令时与冬令时需注意时差变化。
  • always: true:保证即使代码库没有新的提交,定时任务仍会启动Dependabot扫描。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.17 09:37:10