koliveira15 / nx-sonarqube

A Nx plugin that scans projects using SonarQube / SonarCloud.
MIT License
51 stars 21 forks source link

Branches do not work on Azure Devops #74

Closed ricochetbrown closed 8 months ago

ricochetbrown commented 9 months ago

In azure devops, a detached head is created, forcing us to do this with nx:

- script: yarn nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=sonar --parallel=1 env: SONAR_TOKEN: $(SONAR_TOKEN)

When we turn branches: true, it only ever shows 'HEAD' in sonarqube as a result. Using SONAR_BRANCH also does not work because sonar.branch is deprecated and we have to use sonar.branch.name

ricochetbrown commented 9 months ago

let branch = ''; if (options.branches) { branch = execSync('git rev-parse --abbrev-ref HEAD').toString(); }

This code will always return HEAD for Azure Devops

frantisekdolsky commented 8 months ago

Same issue with Github actions on PR build. It's not recognized as PR.

koliveira15 commented 8 months ago

In azure devops, a detached head is created, forcing us to do this with nx:

- script: yarn nx affected --base=$(BASE_SHA) --head=$(HEAD_SHA) --target=sonar --parallel=1 env: SONAR_TOKEN: $(SONAR_TOKEN)

When we turn branches: true, it only ever shows 'HEAD' in sonarqube as a result. Using SONAR_BRANCH also does not work because sonar.branch is deprecated and we have to use sonar.branch.name

@ricochetbrown The original goal was to to determine the branch for the user, but it has become apparent that the plugin cannot account for every CI provider and how it determines the current branch. I am going to replace the branches flag with a branch string property, and it is up to the consumer to pass said property with their nx command

PR

koliveira15 commented 8 months ago

Same issue with Github actions on PR build. It's not recognized as PR.

@frantisekdolsky Please see this comment. Are you looking for Sonar's Pull Request Analysis feature? There are certain properties that the scanner needs to enable that feature which this plugin doesn't support currently.