I have setup TFS 2015 update 3, with several projects. each one of them has its own build definitions, moreover some of those build definition include SonarQube for MS Build tasks (begin-end). so far I setup 1 build agent in other machine to work as a build server, and SonarQube 5.6 instance.
I have been struggling for two days how to solve this issue that appears only in one of the build definitions:
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
checking this error, I analyzed possible causes:
Either way I tried to reproduce the behavior, I logged into the server and tried to make the same calls that build agent perform and I got the same result in the server, but again, this happens just with one of the projects, the other one keeps working perfectly.
I delete the .sonar folder as well as the .sonarqube folder, it keeps giving me that error.
EDIT*
this is the build definition:
{
"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
}
}
After a lot of digging, some sacrifices and many curses I found that targets used by the SonarQube runner for MSBuild were skipped.
One of the targets (SonarQubeImportBeforeInfo) has the condition BuildingInsideVisualStudio != 'true'
. I was using the SAME variable for another inner target (Coincidence)