【问题标题】:Possible causes in error with SonarQube Scanner for MSBuild & TFS 2015SonarQube Scanner for MSBuild & TFS 2015 出错的可能原因
【发布时间】:2017-02-20 11:15:51
【问题描述】:

我已经设置了 TFS 2015 更新 3,其中包含多个项目。它们中的每一个都有自己的构建定义,而且其中一些构建定义包括用于 MS 构建任务的 SonarQube(开始-结束)。到目前为止,我在其他机器上设置了 1 个构建代理作为构建服务器和 SonarQube 5.6 实例。

这两天我一直在苦苦挣扎,如何解决这个只出现在一个构建定义中的问题:

2016-10-11T18:29:54.0515420Z Generating SonarQube project properties file to c:\_work\4\.sonarqube\out\sonar-project.properties
2016-10-11T18:29:54.0525412Z ##[error]The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.
2016-10-11T18:29:54.0525412Z ##[error]Possible causes:
2016-10-11T18:29:54.0535414Z ##[error]1. The project has not been built - the project must be built in between the begin and end steps
2016-10-11T18:29:54.0535414Z ##[error]2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
2016-10-11T18:29:54.0545417Z ##[error]3. The begin, build or end steps have not all been launched from the same folder

检查这个错误,我分析了可能的原因:

  1. 我的构建定义有开始 - 结束任务,所以这应该不是问题
  2. 当前构建服务器使用的是 MSBUILD 14,因此这不是问题
  3. 构建代理运行的任务,我真的希望它从同一目录调用任务。

无论我尝试重现该行为,我登录到服务器并尝试进行与构建代理执行相同的调用,并在服务器中得到相同的结果,但同样,这仅发生在其中一个项目中,另一个继续完美运行。

我删除了 .sonar 文件夹以及 .sonarqube 文件夹,它一直给我这个错误。

编辑*

这是构建定义:

{
  "build": [
    {
      "enabled": true,
      "continueOnError": false,
      "alwaysRun": false,
      "displayName": "Fetch the Quality Profile from SonarQube",
      "task": {
        "id": "eae5b2cc-ac5e-4cba-b022-a06621f9c01f",
        "versionSpec": "*"
      },
      "inputs": {
        "projectKey": "PROJECT1",
        "projectName": "PROJECT1",
        "projectVersion": "1.0",
        "connectedServiceName": "ab3a4128-62ca-4e35-88f0-a2c6aae2a123",
        "dbUrl": "",
        "dbUsername": "",
        "dbPassword": "",
        "cmdLineArgs": "/d:sonar.verbose=true",
        "configFile": "",
        "breakBuild": "false"
      }
    },
    {
      "enabled": true,
      "continueOnError": false,
      "alwaysRun": false,
      "displayName": "Build solution $(Build.SourcesDirectory)\\XXXX\\Build.proj",
      "task": {
        "id": "c6c4c611-aa2e-4a33-b606-5eaba2196824",
        "versionSpec": "*"
      },
      "inputs": {
        "solution": "$(Build.SourcesDirectory)\\XXXX\\Build.proj",
        "platform": "$(BuildPlatform)",
        "configuration": "$(BuildConfiguration)",
        "msbuildArguments": "/p:BuildingInsideVisualStudio=true;FullBuild=true",
        "clean": "false",
        "restoreNugetPackages": "false",
        "logProjectEvents": "false",
        "msbuildLocationMethod": "version",
        "msbuildVersion": "14.0",
        "msbuildArchitecture": "x86",
        "msbuildLocation": ""
      }
    },
    {
      "enabled": true,
      "continueOnError": true,
      "alwaysRun": false,
      "displayName": "Test Assemblies $(Build.SourcesDirectory)\\Droplocation\\**\\XXXX*test*.dll",
      "task": {
        "id": "ef087383-ee5e-42c7-9a53-ab56c98420f9",
        "versionSpec": "*"
      },
      "inputs": {
        "testAssembly": "$(Build.SourcesDirectory)\\Droplocation\\**\\XXXX*test*.dll",
        "testFiltercriteria": "",
        "runSettingsFile": "$(Build.SourcesDirectory)\\Environment\\Test.runsettings",
        "overrideTestrunParameters": "",
        "codeCoverageEnabled": "true",
        "runInParallel": "false",
        "vsTestVersion": "latest",
        "pathtoCustomTestAdapters": "",
        "otherConsoleOptions": "",
        "testRunTitle": "",
        "platform": "$(BuildPlatform)",
        "configuration": "$(BuildConfiguration)",
        "publishRunAttachments": "true"
      }
    },
    {
      "enabled": true,
      "continueOnError": false,
      "alwaysRun": false,
      "displayName": "Finish the analysis and upload the results to SonarQube",
      "task": {
        "id": "730d8de1-7a4f-424c-9542-fe7cc02604eb",
        "versionSpec": "*"
      },
      "inputs": {}
    },
    {
      "enabled": false,
      "continueOnError": false,
      "alwaysRun": false,
      "displayName": "Publish Artifact: $(BuildConfiguration)",
      "task": {
        "id": "1d341bb0-2106-458c-8422-d00bcea6512a",
        "versionSpec": "*"
      },
      "inputs": {
        "CopyRoot": "droplocation\\Build\\$(BuildPlatform)\\$(BuildConfiguration)",
        "Contents": "**\\*",
        "ArtifactName": "$(BuildConfiguration)",
        "ArtifactType": "FilePath",
        "TargetPath": "\\\\SERVER0009\\PROJECT1\\Dev\\FT1\\Droplocation\\Build\\$(BuildPlatform)"
      }
    }
  ],
  "options": [
    {
      "enabled": false,
      "definition": {
        "id": "7c555368-ca64-4199-add6-9ebaf0b0137d"
      },
      "inputs": {
        "multipliers": "[]",
        "parallel": "false",
        "continueOnError": "true",
        "additionalFields": "{}"
      }
    },
    {
      "enabled": false,
      "definition": {
        "id": "a9db38f9-9fdc-478c-b0f9-464221e58316"
      },
      "inputs": {
        "workItemType": "61",
        "assignToRequestor": "true",
        "additionalFields": "{}"
      }
    },
    {
      "enabled": false,
      "definition": {
        "id": "57578776-4c22-4526-aeb0-86b6da17ee9c"
      },
      "inputs": {
        "additionalFields": "{}"
      }
    }
  ],
  "triggers": [
    {
      "schedules": [
        {
          "branchFilters": [
            "+$/PROJECT1"
          ],
          "timeZoneId": "SA Pacific Standard Time",
          "startHours": 2,
          "startMinutes": 0,
          "daysToBuild": 31,
          "scheduleJobId": "d4f0f8c0-00c1-433a-af52-9e1b9e5c3b0c"
        }
      ],
      "triggerType": 8
    }
  ],
  "variables": {
    "BuildPlatform": {
      "value": "AnyCPU"
    },
    "BuildConfiguration": {
      "value": "Debug"
    },
    "system.debug": {
      "value": "true"
    }
  },
  "demands": [
    "gulp",
    "server"
  ],
  "retentionRules": [
    {
      "branches": [
        "+refs/heads/*"
      ],
      "artifacts": [
        "build.SourceLabel"
      ],
      "daysToKeep": 10,
      "minimumToKeep": 1,
      "deleteBuildRecord": true,
      "deleteTestResults": true
    }
  ],
  "_links": {
    "self": {
      "href": "http://SERVERexptfs1:8080/tfs/DevOpsCollection/82853fb4-72eb-4847-8fe3-405d951fdc67/_apis/build/Definitions/6"
    },
    "web": {
      "href": "http://SERVERexptfs1:8080/tfs/_permalink/_build/index?collectionId=498d3af0-ad32-4e5c-9870-7b5ad0346571&projectId=82853fb4-72eb-4847-8fe3-405d951fdc67&definitionId=6"
    }
  },
  "jobAuthorizationScope": 1,
  "jobTimeoutInMinutes": 60,
  "repository": {
    "properties": {
      "labelSources": "0",
      "tfvcMapping": "{\"mappings\":[{\"serverPath\":\"$/PROJECT1/Dev/FT1\",\"mappingType\":\"map\",\"localPath\":\"\\\\\"},{\"serverPath\":\"$/PROJECT1/Dev/FT1/Workspaces\",\"mappingType\":\"cloak\",\"localPath\":\"\\\\Workspaces\"},{\"serverPath\":\"$/PROJECT1/Dev/FT1/Documentation\",\"mappingType\":\"cloak\",\"localPath\":\"\\\\Documentation\"}]}"
    },
    "id": "$/",
    "type": "TfsVersionControl",
    "name": "PROJECT1",
    "url": "http://SERVERexptfs1:8080/tfs/DevOpsCollection/",
    "defaultBranch": "$/PROJECT1/Dev/FT1",
    "rootFolder": "$/PROJECT1",
    "clean": "false",
    "checkoutSubmodules": false
  },
  "quality": 1,
  "authoredBy": {
    "id": "70764a8f-5a60-4969-a13b-771c30beaae8",
    "displayName": "Cristian Galindo Londono",
    "uniqueName": "XXXXINSPECTION\\CGLondono",
    "url": "http://SERVERexptfs1:8080/tfs/DevOpsCollection/_apis/Identities/70764a8f-5a60-4969-a13b-771c30beaae8",
    "imageUrl": "http://SERVERexptfs1:8080/tfs/DevOpsCollection/_api/_common/identityImage?id=70764a8f-5a60-4969-a13b-771c30beaae8"
  },
  "queue": {
    "pool": {
      "id": 1,
      "name": "Default"
    },
    "id": 1,
    "name": "Default"
  },
  "uri": "vstfs:///Build/Definition/6",
  "type": 2,
  "revision": 39,
  "createdDate": "2016-10-13T13:56:02.600Z",
  "id": 6,
  "name": "FT1.Build.Sonar",
  "url": "http://SERVERexptfs1:8080/tfs/DevOpsCollection/82853fb4-72eb-4847-8fe3-405d951fdc67/_apis/build/Definitions/6",
  "project": {
    "id": "82853fb4-72eb-4847-8fe3-405d951fdc67",
    "name": "PROJECT1",
    "url": "http://SERVERexptfs1:8080/tfs/DevOpsCollection/_apis/projects/82853fb4-72eb-4847-8fe3-405d951fdc67",
    "state": "wellFormed",
    "revision": 31
  }
}

【问题讨论】:

  • 你能和我们分享一下这个问题的重现吗?似乎最后一步找不到 .sonarqube/out 文件夹,或者该文件夹不包含任何相关信息(ProjectInfo.xml 文件)。您的解决方案中有哪些类型的项目?
  • 由于该问题仅出现在一个构建定义中,因此该问题应该与 TFS 环境无关。你能告诉我们你在这个构建定义中使用了什么样的项目吗?据本站docs.sonarqube.org/display/SCAN/…称,不支持对BizTalk、SharePoint、ASP.NET vNext项目、Web Site Solutions的分析。
  • 是一组c#库项目。事实上,在文件夹 .sonarqube/out 文件夹中没有与项目相关的信息。我处于调查模式,由于这个构建定义正在工作,试图找出哪些变化并影响其正常工作
  • 我创建了一个执行进程的powershell脚本,它工作正常,为什么TFS任务继续失败???呸呸呸
  • 能否分享详细的构建定义设置和测试项目?

标签: msbuild sonarqube tfsbuild sonar-runner


【解决方案1】:

经过大量挖掘、一些牺牲和许多诅咒,我发现 SonarQube runner 用于 MSBuild 的目标被跳过了。

其中一个目标 (SonarQubeImportBeforeInfo) 具有条件 BuildingInsideVisualStudio != 'true' 。我将 SAME 变量用于另一个内部目标(巧合)

【讨论】:

    猜你喜欢
    • 2017-02-20
    • 2018-05-12
    • 1970-01-01
    • 2017-01-13
    • 2018-08-27
    • 1970-01-01
    • 2018-08-15
    • 2017-01-26
    • 2016-07-05
    相关资源
    最近更新 更多