【问题标题】:How to run specific script by specific schedule in Azure devOps?如何在 Azure devOps 中按特定计划运行特定脚本?
【发布时间】:2023-06-10 13:01:01
【问题描述】:

我有两个时间表第一个10分钟运行我的测试,第二个运行我的凌晨 1 点进行测试。我希望 第一个计划 只运行 npm run cy:healthCheck 脚本和第二个计划 npm run cy:test 脚本。我怎样才能达到这种行为。

这是仅每 10 分钟运行一次我的 npm run cy:healthCheck 脚本的 YAML 文件 - Pastebin link of YAML

【问题讨论】:

  • 如果以下回复对您有帮助,您可以Accept it as an Answer,这对阅读此主题的其他社区成员会有所帮助。

标签: azure-devops continuous-integration yaml cypress schedule


【解决方案1】:

我看到两个选项

  1. 从现有管道创建模板,然后使用具有不同计划和参数的模板创建 2 个管道,以运行一个或第二个任务。
  2. 在一个管道中有两个计划,例如 here 添加任务以计算条件变量
schedules:
- cron: "0 0 * * *"
  displayName: Daily midnight build
- cron: "0 12 * * 0"
  displayName: Weekly Sunday build

- powershell: |
        $a=get-date
        if($a.Hour -eq 11 -and ($a.Minute -lt 5 -or $a.Minute -gt 55))
        {
            $TimeToRunSecondTask=(1 -eq 1)
        }       
          Write-Output "##vso[task.setvariable variable=FileExists]$TimeToRunSecondTask"   
- task: 
  condition: eq(variables['TimeToRunSecondTask'], True)

【讨论】:

  • 拥有 2 个 yaml 文件可以解决我的问题。你认为这是解决我问题的好方法吗?
  • 我将创建从这 2 个管道调用的模板以不重复代码。
最近更新 更多