Disable Pull Request analysis Sonarcloud+Bitbucket+Azure Pipelines

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

image

Hi,

Welcome to the community!

Can you share your pipeline?

 
Ann


Hi, thanks for replying, this is my pipeline

Hi,

This starts with the steps. Do you not define branches: and/or pull requests: in there?

 
Ann

Hi Ann,

No, I dont have any defitions for branches or PRs, just this:
image

After that, I call other steps, like this:

Hi,

Could we have the text version - redacted as necessary - of the whole thing?

 
Ann

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'

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

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?

Hi,

Does this relate to this thread?

 
Ann

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! :slight_smile: