Azure DevOps 部署失败并显示错误消息 "The operation was canceled."

Azure DevOps deployment fails with the error message "The operation was canceled."

我的 Azure DevOps 管道任务成功完成,除了最后的部署步骤外没有任何问题:

Job Issues - 1 Error
The job running on agent XXXX ran longer than the maximum time of 00:05:00 minutes. For more information, see https://go.microsoft.com/fwlink/?linkid=2077134

生成日志表明操作已取消:

021-03-02T20:50:00.4223027Z Folders: 695
2021-03-02T20:50:00.4223319Z Files: 10645
2021-03-02T20:50:00.4223589Z Size:       672611102
2021-03-02T20:50:00.4223851Z Compressed: 249144045
2021-03-02T20:50:03.6023001Z ##[warning]Unable to apply transformation for the given package. Verify the following.
2021-03-02T20:50:03.6032907Z ##[warning]1. Whether the Transformation is already applied for the MSBuild generated package during build. If yes, remove the <DependentUpon> tag for each config in the csproj file and rebuild. 
2021-03-02T20:50:03.6034584Z ##[warning]2. Ensure that the config file and transformation files are present in the same folder inside the package.
2021-03-02T20:50:04.5268038Z Initiated variable substitution in config file : C:\azagent\A2\_work\_temp\temp_web_package_3012195912183888\Areas\Admin\sitemap.config
2021-03-02T20:50:04.5552027Z Skipped Updating file: C:\azagent\A2\_work\_temp\temp_web_package_3012195912183888\Areas\Admin\sitemap.config
2021-03-02T20:50:04.5553082Z Initiated variable substitution in config file : C:\azagent\A2\_work\_temp\temp_web_package_3012195912183888\web.config
2021-03-02T20:50:04.5642868Z Skipped Updating file: C:\azagent\A2\_work\_temp\temp_web_package_3012195912183888\web.config
2021-03-02T20:50:04.5643366Z XML variable substitution applied successfully.
2021-03-02T20:51:00.8934630Z ##[error]The operation was canceled.
2021-03-02T20:51:00.8938641Z ##[section]Finishing: Deploy IIS Website/App: 

当我检查部署状态时,我注意到我的一项任务需要相当长的时间来执行一个应该相当简单的操作:

文件转换部分占用了分配的 5 分钟的一半?这可能是问题所在吗?

steps:
- task: FileTransform@1
  displayName: 'File Transform: '
  inputs:
    folderPath: '$(System.DefaultWorkingDirectory)/_site.com/drop/Release/Nop.Web.zip'
    fileType: json
    targetFiles: '**/dataSettings.json'

它可能效率低下,但 FileTransform 日志显示在替换变量后花费了大量时间。不确定是什么导致了长时间的延迟,但是日志没有说明变量被成功替换后的时间:

2021-03-02T23:04:44.3796910Z Folders: 695
2021-03-02T23:04:44.3797285Z Files: 10645
2021-03-02T23:04:44.3797619Z Size:       672611002
2021-03-02T23:04:44.3797916Z Compressed: 249143976
2021-03-02T23:04:44.3970596Z Applying JSON variable substitution for **/App_Data/dataSettings.json
2021-03-02T23:04:45.2396016Z Applying JSON variable substitution for C:\azagent\A2\_work\_temp\temp_web_package_0182869515217865\App_Data\dataSettings.json
2021-03-02T23:04:45.2399264Z Substituting value on key DataConnectionString with (string) value: ***
**2021-03-02T23:04:45.2446986Z JSON variable substitution applied successfully.
2021-03-02T23:07:25.4881687Z ##[section]Finishing: File Transform:** 

The job running on agent XXXX ran longer than the maximum time of 00:05:00 minutes.

根据错误信息,出现此问题的原因是运行 Agent Job 的时间已达到设置的最大值。

如果您正在使用发布管道,您可以在 Agent Job -> Execution plan ->timeout 中设置超时。

如果您正在使用构建管道,您可以在 Agent Job -> Agent Job -> Execution plan -> timeout(对于代理作业)和 Options -> Build job -> Build job timeout in minutes(对于整个构建管道)中设置超时。

The file transform portion takes over half of the allotted 5 minutes

从任务日志来看,压缩包中包含很多文件和文件夹。因此,transform任务会花费更多的时间遍历文件寻找目标文件。