Manuel
(Manuel)
July 21, 2022, 4:05pm
1
Hi everyone,
I have a couple of repositories which are being analyzed by Sonarcloud, I would like to only analyze the short and long lived branch, not the Pull Request, or find a way to ignore the failed quality gate of the Pull Request Analysis in bitbucket so I merge the PR.
Thanks in advance!
ALM used: Bitbucket Cloud
CI system used: Azure Pipelines
Scanner command used when applicable (private details masked)
Languages of the repository: Javascript
ganncamp
(G Ann Campbell)
July 21, 2022, 4:43pm
2
Hi,
Welcome to the community!
Can you share your pipeline?
Ann
Manuel
(Manuel)
July 21, 2022, 5:32pm
3
Hi, thanks for replying, this is my pipeline
ganncamp
(G Ann Campbell)
July 21, 2022, 5:42pm
4
Hi,
This starts with the steps. Do you not define branches:
and/or pull requests:
in there?
Ann
Manuel
(Manuel)
July 21, 2022, 6:06pm
5
Hi Ann,
No, I dont have any defitions for branches or PRs, just this:
After that, I call other steps, like this:
ganncamp
(G Ann Campbell)
July 21, 2022, 6:29pm
6
Hi,
Could we have the text version - redacted as necessary - of the whole thing?
Ann
Manuel
(Manuel)
July 21, 2022, 6:33pm
7
Sure, this is the main file:
trigger:
- develop
pr: none
stages:
- stage: Configure_Test_and_Build
jobs:
- job: Sonarcloud
displayName: Testing and Sonarcloud Analysis
steps:
- template: pipeline-templates/test.yml
=============================
this is the test.yml
steps:
- bash: echo "##vso[task.setvariable variable=node_version]$(cat .nvmrc)"
displayName: Get node version
- task: NodeTool@0
inputs:
versionSpec: $(node_version)
- task: Cache@2
inputs:
key: 'yarn | "$(Agent.OS)" | yarn.lock'
restoreKeys: |
yarn | "$(Agent.OS)"
yarn
path: /home/vsts/.cache/yarn
displayName: Cache Yarn packages
- script: yarn --frozen-lockfile
- script: |
yarn install
displayName: Install local dependecies
- script: |
yarn run test:cov
displayName: Run tests with coverage report
- task: SonarCloudPrepare@1
continueOnError: true
displayName: Preparing repository data for Sonar analysis
inputs:
SonarCloud: 'SonarcloudConnection'
organization: 'myOrganization'
scannerMode: 'CLI'
configMode: 'manual'
cliProjectKey: 'myProjectKey'
cliProjectName: 'myProjectName'
cliSources: '.'
- task: SonarCloudAnalyze@1
continueOnError: true
displayName: Executing Sonar analysis
- task: SonarCloudPublish@1
continueOnError: true
displayName: Uploading analysis results to Sonarcloud
inputs:
pollingTimeoutSec: '300'
ganncamp
(G Ann Campbell)
July 21, 2022, 7:15pm
8
Hi,
Thanks for this.
I’m new to Azure pipelines. From what I’m seeing online, it’s more typical to have this syntax:
trigger:
branches:
- develop
I’m wondering if the difference in syntax is causing a misfire on the pr: none
…
Ann
Manuel
(Manuel)
July 21, 2022, 7:30pm
9
Actually when a PR to develop is created it runs a desired build, however I dont want to it to be analyzed by Sonarcloud, just when I pushed changes to a branch. Is this possible?
ganncamp
(G Ann Campbell)
July 22, 2022, 12:14pm
10
Hi,
Does this relate to this thread?
Hi, a couple of days ago I’ve noticed that Sonarcloud stopped posting updates on code analysis for my PRs.
There was a Pull request that took more than 10 days and I could see that commits from 7 days ago had the report updated, but fresh ones from 1-2 days ago don’t.
I had a suspicion that the token expired.
But when I go to the list of checks for the PR it has the report there, which means that that’s not the issue.
I’m not sure where I should be looking anymore
Ann
Manuel
(Manuel)
July 22, 2022, 1:24pm
11
Hi,
thanks Ann, I’ll try to find that approach on Azure Pipelines. If someone knows how to do it, I’ll appreciate the support!