TFS 2018 Update 2 with SonarQube Publish Quality Gate fails

we have a build definition that works in TFS 2015 but fails for the 2018 build.
The step that fails is Publish Quality Gate Results for SonarQube TFS Extension

2018-06-08T15:42:33.9489603Z ##[debug]SONARQUBE_ENDPOINT=********
2018-06-08T15:42:33.9492101Z ##[debug][SQ] API GET: '/api/metrics/search' with
query "{"f":"name","ps":500}"
2018-06-08T15:42:34.0367293Z ##[debug]Response: 401 Body: "undefined"
2018-06-08T15:42:34.0368671Z ##[debug][SQ] API GET '/api/metrics/search' failed, status code was: 401
2018-06-08T15:42:34.0369703Z ##[error][SQ] Could not fetch metrics
2018-06-08T15:42:34.0370610Z ##[debug]Processed: ##vso[task.issue type=error;][SQ] Could not fetch metrics
2018-06-08T15:42:34.0371656Z ##[error][SQ] API GET '/api/metrics/search' failed, status code was: 401
2018-06-08T15:42:34.0372504Z ##[debug]Processed: ##vso[task.issue type=error;][SQ] API
GET '/api/metrics/search' failed, status code was: 401
2018-06-08T15:42:34.0373426Z ##[debug]Agent.BuildDirectory=D:\source\agent_work\21
2018-06-08T15:42:34.0369703Z ##[error][SQ] Could not fetch metrics
2018-06-08T15:42:34.0370610Z ##[debug]Processed: ##vso[task.issue type=error;][SQ] Could not fetch metrics
2018-06-08T15:42:34.0371656Z ##[error][SQ] API GET '/api/metrics/search' failed, status code was: 401
```

I have found that removing the extension and reinstalling it fixed the issue.

1 Like

You have probably used an old version of SonarQube extension on TFS2015, but it doesn’t work with TFS 2018.

The solution is to install the latest version of extension on Visual Studio Marketplace.

It works with:
Team Foundation Server 2017 Update 2
Team Foundation Server 2017 Update 3
Team Foundation Server 2018 Update 2