Reputation: 491
I am trying to add the Sonar analysis task into a Yaml build definition for VSTS.
I've generated the Yaml from an existing build which isn't Yaml and it generated the following:
- task: SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubeScannerMsBuildBegin@3
inputs:
projectKey: 'mykey'
projectName: 'projectName'
projectVersion: '$(Build.BuildNumber)'
connectedServiceName: 'SonarQube'
However I get an instant build failure:
Step input connectedServiceName references endpoint SonarQube which could not be found. The service endpoint does not exist or has not been authorized for use.
The service name is correct and works for the non-yaml version. So I am not sure how to resolve. When I look through https://github.com/Microsoft/vsts-tasks/tree/master/Tasks/ for examples of the Yaml synax I can't see Sonar at all. So I did wonder if this taks is not actually supported
Updated:
I was using v3 of the task so I have updated to v4 the yaml now the following:
- task: SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
inputs:
SonarQube: 'ab0ef446-6a80-xxxx-xxxx-xx...'
projectKey: 'mykey'
projectName: 'myname'
projectVersion: '$(Build.BuildNumber)'
However I still receive the following error:
Step input SonarQube references endpoint ab0ef446-6a80-xxxx-xxxx-xx... which could not be found. The service endpoint does not exist or has not been authorized for use
Upvotes: 0
Views: 2373
Reputation: 5326
I think the problem come from the fact you are experimenting on a branch (not on master). Seems that authorization to get endpoint is depending on the fact your yaml is on the master branch.
See YAML getting started - Endpoints and YAML getting started - Authorization
Update: previous links are now part of outdated documentation. Latest documentation is Service Connections - Use a service connection and doesn't mention any constraint. But I found this comment that still implies that endpoint should be declared in the default branch:
Also make sure the changes you are making are being pushed to the default branch (or change your default branch). This way the service endpoint that you have create is authorized.
Upvotes: 1