SonarQube Scanner for MSBuild& amp;错误的可能原因。 TFS 2015

时间:2016-10-11 19:35:29

标签: msbuild sonarqube tfsbuild sonar-runner

我已经设置了多个项目的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. 构建代理运行的任务,我真的希望它从同一目录调用任务。
  4. 无论哪种方式我尝试重现行为,我登录到服务器并尝试进行构建代理执行的相同调用,我在服务器中得到相同的结果,但同样,这只发生在其中一个项目中,另一个保持完美的工作。

    我删除了.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
      }
    }
    

1 个答案:

答案 0 :(得分:1)

经过大量挖掘,一些牺牲和许多诅咒后,我发现SonarQube跑步者为MSBuild使用的目标被跳过了。

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