- ALM used: Azure DevOps
- CI system used: Azure DevOps
- Languages of the repository : Front-end - Javascript/Typescript (React), Back-end - C#/.net
- What am I trying to achieve? : I am trying to confirm that sonarcloud is reporting in my front end repo in azure devops without issue (details below)
Hi All - Sorry in advance for my lack of knowledge as I am new to Azure Devops and SonarCloud.
As per the above, I’ve got two repo’s under the same project on azure devops I am working on currently, one for the front-end and one for the back-end. I am trying to confirm that sonarcloud is scanning my code correctly whenever a pull request is created in each repo but I am getting the below from my front-end repo whenever it has a pull request made from a branch.
I’ve confirmed that SonarCloud is reporting the results in my back-end pull requests without issue so I am getting a little stuck as to where I might be going wrong with it. I’ve currently got my yaml file for the front end set to to the following (private replaced with test project)
trigger:
- main
variables:
vmImageName: 'ubuntu-20.04'
stages:
- stage: ci
displayName: 'CI'
jobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)
steps:
- task: UseNode@1
displayName: 'Use Node 16x'
inputs:
version: 16.x
- task: YarnInstaller@3
displayName: 'install yarn'
inputs:
versionSpec: '1.x'
checkLatest: true
- task: Yarn@3
displayName: 'install modules'
inputs:
arguments: 'install'
- task: SonarCloudPrepare@1
displayName: 'Prepare analysis on SonarCloud'
inputs:
SonarCloud: 'SonarCloud'
organization: 'TestOrg'
scannerMode: CLI
configMode: 'file'
configFile: 'sonar-project.properties'
projectKey: 'TestKey'
projectName: 'TestProject'
cliSources: '.'
- task: Yarn@3
displayName: 'test and collect coverage'
inputs:
arguments: 'vitest run --coverage'
- task: SonarCloudAnalyze@1
displayName: 'Run Code Analysis'
- task: SonarCloudPublish@1
displayName: Publish Quality Gate Result
inputs:
pollingTimeoutSec: '300'
- task: Yarn@3
displayName: 'build application'
inputs:
arguments: 'build'
- stage: dockerbuild
displayName: 'DockerBuild'
dependsOn:
- ci
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
jobs:
- job: DockerBuild
displayName: 'Build'
pool:
vmImage: ubuntu-latest
steps:
- task: Docker@2
inputs:
containerRegistry: 'TestProjectDockerRegistry'
repository: 'frontend'
command: 'buildAndPush'
Dockerfile: '**/Dockerfile'
tags: '$(Build.BuildNumber)'
I will note that the pull requests do have a slight difference when viewing sonarcloud dashboard - see below for example.
I’ve checked other posts on the forms and doesn’t seem to be a PAT issue since the back end works fine so I am little stumped as to what is going wrong.
Any help would be appreciated