英文:
Azure cron pipeline always runs
问题
根据您提供的信息,您已经设置了一个Azure管道,用于每天运行GUI测试两次。根据文档,它应该只在代码发生更改时运行,但它总是运行。
这是我的"azure-pipelines-cypress.xml"中的cron计划:
schedules:
- cron: "0 10 * * *"
displayName: 每天 12:00 构建 (UTC 10:00)
branches:
include:
- master
请注意文档(https://learn.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops&tabs=yaml#scheduled-triggers)中所述:
always: boolean # 是否始终运行管道,还是仅在上次运行以来有源代码更改时运行。默认值为false。
这只是一个简单的错误吗,还是我漏掉了什么?
英文:
I have set up an Azure pipeline to run GUI tests twice a day. According to the documentation, it should only run if there have been code changes, but it always runs.
This is my cron schedule in "azure-pipelines-cypress.xml"
schedules:
- cron: "0 10 * * *"
displayName: Daily 12:00 build (UTC 10:00)
branches:
include:
- master
Note that the documentation (https://learn.microsoft.com/en-us/azure/devops/pipelines/process/scheduled-triggers?view=azure-devops&tabs=yaml#scheduled-triggers) states:
> always: boolean # whether to always run the pipeline or only if there have been source code changes since the last run. The default is false.
Is this simply a bug or am I missing something?
答案1
得分: 7
-
Update2:
> 我不希望它每次主分支更新时都运行。它应该在主分支更新时运行,并且只在计划时间内运行。
> 但这难道不是我当前流水线的预期行为吗?当前的行为就好像我已经设置了"always: true"。
首先,感谢Mick耐心提供了大量详细信息。
现在,我明白了问题,并且我在我的一侧复制了这个问题。如果我们设置了计划触发器,但构建结果失败了。在这种情况下,即使我们没有做任何更改,计划触发器仍然会触发。这是因为最新的构建失败了,所以流水线没有记录上次提交的记录。当达到计划的时间时,上次提交/源代码更改仍然存在。这将触发计划的触发器。
所以,这就是为什么你的流水线仍然执行,即使你在代码/yaml中没有做任何更改的原因。
如果我成功构建了流水线,计划触发器将按预期工作。
因此,可以说文档不够清楚,它应该是:
> always: boolean # 是否始终运行流水线,或仅在自上次成功运行以来有源代码更改时运行。默认为false。
我已经提交了这个问题给微软,感谢您帮助我们构建更好的Azure DevOps。
希望这有所帮助。
英文:
> Azure cron pipeline always runs
Update2:
> I don't want it to run every time the master branch is updated. It
> should run when the master branch is updated AND only at a scheduled
> time.
>
> But is that not the expected behavior of my current pipeline? The
> current behavior acts as if I had set "always: true"
First of all, thanks Mick for your patience in providing a lot of detailed information.
Now, I figure out the issue and I could reproduce this issue on my side. If we set the scheduled triggers, but the build result is failed. In this case, even if we do not any change, the scheduled triggers will still fire. That because the latest build failed, so the last commit record was not recorded by the pipeline. When the scheduled time is reached, the last commit/source code change still exists. It will trigger scheduled triggers.
So, that the reason why your pipeline still executed, even if you do not do any change in the code/yaml.
If I successfully build the pipeline, the scheduled triggers works as expected.
So, it should be said that the documentation is not clear enough, it should be:
> always: boolean # whether to always run the pipeline or only if there
> have been source code changes since the last successful run. The
> default is false.
I submit this to MS, Thank you for helping us build a better Azure DevOps.
Hope this helps.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论