Azure devops 管道初始化作业失败并显示错误消息“#[error]bad content type”

Azure devops pipeline Initialize Job Failing with the error message " #[error]bad content type "

我们在本地部署了 Azure-DevOps。 我的构建管道也与 SonarQube 任务完美配合。 然后突然我得到一个错误,因为文件 "Access to the path_work\a\MyProject.API.dll.RoslynCA.json" 的某些访问问题被拒绝。

我已经删除了那个文件,如果这是自动生成的文件,我会再次得到它。但是运气不好,出现了同样的错误。

我删除了文件夹 "sonarqubePrepare" 并开始面临另一个错误 - 错误 - "Bad content type"。 (注意 - 只有当我执行 sonarqube 任务时才会出现此错误,MSBUILD 任务工作正常)

我已重新安装代理并尝试再次执行管道。但同样的问题是现在 id "##[error]Bad content type".

注意-SonarQube 任务与其他构建机器上的其他项目一起工作正常。

日志-

2019-06-10T13:03:01.22402Z ##[section]Starting: Initialize job

2019-06-10T13:03:01.22572Z Current agent version: '2.141.1'

2019-06-10T13:03:01.238990Z ##[debug]Primary repository: MyRepo.

 repository type: Tfvc

2019-06-10T13:03:01.249208Z Prepare build directory.

2019-06-10T13:03:01.28078Z ##[debug]Delete existing artifacts directory: 'E:\vsts-agent-win-x64-2.141.1\_work\a'

2019-06-10T13:03:01.280467Z ##[debug]Deleting artifacts directory: 'E:\vsts-agent-win-x64-2.141.1\_work\a'

2019-06-10T13:03:01.282948Z ##[debug]Creating artifacts directory: 'E:\vsts-agent-win-x64-2.141.1\_work\a'

2019-06-10T13:03:01.283370Z ##[debug]Delete existing test results directory: 'E:\vsts-agent-win-x64-2.141.1\_work\TestResults'

2019-06-10T13:03:01.283321Z ##[debug]Deleting test results directory: 'E:\vsts-agent-win-x64-2.141.1\_work\TestResults'

2019-06-10T13:03:01.283687Z ##[debug]Creating test results directory: 'E:\vsts-agent-win-x64-2.141.1\_work\TestResults'

2019-06-10T13:03:01.2841036Z Set build variables.

2019-06-10T13:03:01.290128Z Download all required tasks.

2019-06-10T13:03:01.35085Z Downloading task: SonarQubePrepare

2019-06-10T13:03:01.61385Z ##[error]bad content type

2019-06-10T13:03:01.61594Z ##[debug]System.Exception: bad content type

at Microsoft.TeamFoundation.DistributedTask.WebApi.TaskAgentHttpClient.GetTaskContentZipAsync(Guid taskId, TaskVersion version, Object userState, CancellationToken cancellationToken)

at Microsoft.VisualStudio.Services.Agent.Worker.TaskManager.DownloadAsync(IExecutionContext executionContext, TaskStepDefinitionReference task)

at Microsoft.VisualStudio.Services.Agent.Worker.TaskManager.DownloadAsync(IExecutionContext executionContext, IEnumerable`1 steps)

at Microsoft.VisualStudio.Services.Agent.Worker.JobExtension.InitializeJob(IExecutionContext jobContext, AgentJobRequestMessage message)
2019-06-10T13:03:01.6162764Z ##[section]Finishing: Initialize job

首先处理第二个错误,因为这会阻止您重现原始错误:

由...

I have removed folder "sonarqubePrepare"

...你是说你从构建代理中删除了任务文件夹,即一个名为类似的文件夹 C:\agents\myagent\_work\_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157?

如果是这样,这不是 SonarQube Prepare 任务本身的错误。您通过删除任务文件夹破坏了构建代理的配置,并且构建代理本身在尝试确保代理上存在正确的任务文件时抛出错误。仅供参考,该文件夹不包含任何临时 build-specific 文件 - 它仅包含实现任务逻辑的静态文件。

尝试在构建代理的单独文件夹中重新安装构建代理。