Our SonarCloud organisation is bound to a BitBucket organisation. As an agency we work with many client owned repositories spread between BitBucket and GitHub and we would like to leverage our existing SonarCloud organisation on each of them.
We have set up a sonar scan workflow and while running the workflow on push
events only we could see results within SonarCloud - although the results of the scan were not appearing as Checks on PRs.
After updating the workflow to run on pull_request
also we see new errors in the scan logs. See below:
name: Pipeline
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
permissions: write-all
jobs:
sonar-scan-quality-gate:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# Disabling shallow clone is recommended for improving relevancy of reporting
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.16.x
cache: yarn
- name: Lint
run: |
yarn install
yarn report
- name: SonarCloud Scan
uses: sonarsource/sonarcloud-github-action@master
env:
# Needed to get PR information
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
args: >
-Dsonar.projectKey=[SONAR_PROJECT_KEY]
-Dsonar.organization=[SONAR_ORG]
-Dsonar.sources=src
-Dsonar.inclusions=src/**
-Dsonar.javascript.node.maxspace=4096
-Dsonar.css.stylelint.reportPaths=.reports/stylelint.json
-Dsonar.eslint.reportPaths=.reports/eslint.json
-Dsonar.pullrequest.provider=GitHub
-Dsonar.pullrequest.github.repository=[GH_ORG]/[GH_REPO]
Log:
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.7.0.2747
INFO: Java 11.0.17 Alpine (64-bit)
INFO: Linux 5.15.0-1024-azure amd64
INFO: User cache: /opt/sonar-scanner/.sonar/cache
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: Analyzing on SonarCloud
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=739ms
INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
INFO: User cache: /opt/sonar-scanner/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=682ms
INFO: Load/download plugins (done) | time=4001ms
INFO: Loaded core extensions: developer-scanner
INFO: Found an active CI vendor: 'Github Actions'
INFO: Load project settings for component key: '[SONAR_PROJECT_KEY]'
INFO: Load project settings for component key: '[SONAR_PROJECT_KEY]' (done) | time=660ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=3ms
INFO: Project key: [SONAR_PROJECT_KEY]
INFO: Base dir: /github/workspace
INFO: Working dir: /github/workspace/.scannerwork
INFO: Load project branches
INFO: Load project branches (done) | time=709ms
INFO: Check ALM binding of project '[SONAR_PROJECT_KEY]'
INFO: Detected project binding: BOUND
INFO: Check ALM binding of project '[SONAR_PROJECT_KEY]' (done) | time=650ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=677ms
INFO: Load branch configuration
INFO: Github event: pull_request
INFO: Auto-configuring pull request 36
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 15.542s
INFO: Final Memory: 19M/67M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: Could not find the pullrequest with key '36'
ERROR: Caused by: Error 404 on https://sonarcloud.io/api/alm_integration/show_pullrequest?project=[SONAR_PROJECT_KEY]&pullrequestKey=36 : {"errors":[{"msg":"Not Found"}]}
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
Any help would be appreciated.