Azure DevOps 部署失败并显示错误消息“操作已取消。”

时间:2021-03-02 23:11:38

标签: deployment azure-devops azure-pipelines

我的 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: 

当我检查部署状态时,我注意到我的一项任务需要很长时间才能完成一个应该相当简单的操作:

enter image description here

文件转换部分占用了分配的 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:** 

1 个答案:

答案 0 :(得分:0)

<块引用>

在代理 XXXX 上运行的作业运行时间超过了最大时间 00:05:00 分钟。

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

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

enter image description here

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

enter image description here

<块引用>

文件转换部分占用了分配的 5 分钟的一半

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