Search code examples
next.jssonarqubegithub-actionsgithub-actions-self-hosted-runners

Sonar on - Self Hosted Runner - Cant use npm to coverage and docker together


When i try to run (action checkout) on self hosted runner with npm run coverage and after sonarqube i got this error:" docker: Error response from daemon: pull access denied for 6cd1db, repository does not exist or may require 'docker login': denied: requested access to the resource is denied. It works without the checkout and npm commands... Any tip?

build.yml file was like:

name: Build

on:
  push:
    branches:
      - main
  pull_request:
    types: [opened, synchronize, reopened]
jobs:
  build:
    name: Sonar Scan
    runs-on:
      - self-hosted
    steps:
      - uses: actions/setup-node@v3
        with:
          node-version: 16.15.0
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0  # Shallow clones should be disabled for a better relevancy of analysis
      - run: npm install
      - run: npm run coverage
      - uses: sonarsource/sonarqube-scan-action@master
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
          SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
      # If you wish to fail your job when the Quality Gate is red, uncomment the
      # following lines. This would typically be used to fail a deployment.
      # We do not recommend to use this in a pull request. Prefer using pull request
      # decoration instead.
      - uses: sonarsource/sonarqube-quality-gate-action@master
        timeout-minutes: 5
        env:
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

Solution

  • Use actions/checkout@v3 instead of actions/checkout@v2, since you are using Node v16.

    v2 do not support v16. Read more about the migration: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/