Github Action - Self hosted Runner - Project Setting None

I am using SonarSource/sonarcloud-github-action@master in Github Actions. I have setup a build using a self-hosted runner. All is working fine except that the sonarqube build dont find the sonar-project.properties. If i am using the Runner hosted by github, sonarqube find the file. The configuration is exact the same. The file is on both runners visible and readable.

Log of the failed build:

Run SonarSource/sonarcloud-github-action@master
  with:
    projectBaseDir: .
  env:
    SSH_AUTH_SOCK: /tmp/ssh-R8C3YtUZH7g4/agent.2099
    SSH_AGENT_PID: 2100
    GITHUB_TOKEN: ***
    SONAR_TOKEN: ***
/usr/bin/docker run --name b1cbc55d9ffb630d634d4184edd31919b340d4_4fa637 --label b1cbc5 --workdir /github/workspace --rm -e SSH_AUTH_SOCK -e SSH_AGENT_PID -e GITHUB_TOKEN -e SONAR_TOKEN -e INPUT_PROJECTBASEDIR -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/***/***":"/github/workspace" b1cbc5:5d9ffb630d634d4184edd31919b340d4
INFO: Scanner configuration file: /opt/sonar-scanner/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarScanner 4.3.0.2102
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 4.15.0-96-generic amd64
INFO: User cache: /root/.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: "US-ASCII" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=191ms
INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=83ms
INFO: Load/download plugins (done) | time=21254ms
INFO: Loaded core extensions: developer-scanner
INFO: Process project properties
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 25.358s
ERROR: Error during SonarScanner execution
INFO: Final Memory: 6M/24M
ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.organization
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
INFO: ------------------------------------------------------------------------ ```

I cant find any solutions for that. Anyone has an idea?

Kind Regards

Helllo? Are there any Members or Mods that try to help me?

Hello @ModdyLP,

Do you confirm that the sources are available in the working directory before executing the SonarCloud step?

Could you share the full set-up of your runners and workflow (it is possible to share these privately through a PM)

I have confirmed that the project folder is accessable and sonarqube use it. Because if i change the folder to something not exists or make it empty sonarqube throws an exception which tell me that the folder is missing. In exactly this folder lays the configuration file.

The Job Configuration:
name: Node CI

on: [push, pull_request]

jobs:
  build:
    name: Test

runs-on: self-hosted

steps:
  - name: Checkout Repo
    uses: actions/checkout@master
    with:
      fetch-depth: 0

  - name: Use Node.js
    uses: actions/setup-node@master
    with:
      node-version: '10.x'

  - uses: webfactory/ssh-agent@v0.4.0
    with:
      ssh-private-key: ${{ secrets.private_ssh }}

  - name: Get yarn cache directory path
    id: yarn-cache-dir-path
    run: echo "::set-output name=dir::$(yarn cache dir)"

  - uses: actions/cache@v2
    id: yarn-cache # used to check for cache-hit: if: steps.yarn-cache.outputs.cache-hit != 'true'
    with:
      path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
      key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
      restore-keys: |
        ${{ runner.os }}-yarn-
  - name: Install dependencies
    run: yarn

  - name: Check style
    run: yarn run lint

  - name: Run tests
    run: yarn run test-coverage

sonarCloudTrigger:
needs: build
name: SonarCloud Trigger
runs-on: self-hosted
steps:
  - name: Clone Repository
    uses: actions/checkout@master
  - name: Analyze with SonarCloud
    uses: sonarsource/sonarcloud-github-action@master
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

And the sonar-project.properties (escaped sensitive infos)

sonar.projectKey=---projectkey---
sonar.organization=--organization--
sonar.sourceEncoding=UTF-8
sonar.projectName=--name--
sonar.links.homepage=https://----.de
sonar.javascript.file.suffixes=.js,.jsx
sonar.links.ci=https://github.com/-------/actions
sonar.links.issue=https://github.com/----/issues
sonar.links.scm=https://github.com/----
sonar.sources=src
sonar.tests=src
sonar.test.inclusions=**/*.test.*
sonar.testExecutionReportPaths=test-report.xml
sonar.javascript.lcov.reportPaths=coverage/lcov.info

I have found the problem. The Problem was that i executed the actions-runner in a docker-container and the sonarqube docker container does not take the correct path to the working folder. So if i change the working folder of the actions-runner to /home/runner/work than all goes right and the sonarqube job works as espected.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.