Hello there
Must-share information (formatted with Markdown):
- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
Sonarqube server version : Community Edition Version 9.0.1 (build 46107)
Sonarscanner image : sonarsource/sonar-scanner-cli:latest
Gitlab version : 14.4.2
Gitlab-runner version : 13.9.0
- what are you trying to achieve
I’m actually trying to scan a Gitlab repository, which is in fact a submodule in another repository.
We actually have a “Code” repository in a parent repo. The pipeline is triggered by the submodule using this :
stages:
- master-check
auto-check-code:
stage: master-check
trigger:
project: clients/parent/parent
branch: master
strategy: depend
variables:
SUB_COMMIT_NAME: $CI_COMMIT_SHA
SUB_BRANCH_NAME: $CI_COMMIT_BRANCH
My gitlab-ci file look like this on the parent repo, sonar part only :
sonarqube-check:
stage: test-build
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
GIT_SUBMODULE_STRATEGY: recursive
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
allow_failure: true
tags:
- sonar
rules:
- when: always
Also, my sonar-project.properties file looks like this :
sonar.projectKey=clients_parent_parent_token
sonar.qualitygate.wait=true
sonar.projectBaseDir=code
sonar.exclusions=<Exclusions here>
sonar.qualitygate.timeout=1200
sonar.projectName=MyProject
I’ve configured the parent repository using the guided steps in sonarqube for adding a new gitlab repository :
- Generating a project key, and adding sonar-project.properties file at repo root path.
- Generating a SONAR_TOKEN and added it in gitlab CI variables, aswell as the SONAR_HOST_URL
- Trigger the pipeline
Perhaps, when the pipeline is running, i’m getting this error :
Running with gitlab-runner 13.9.0 (2ebc4dc4)
on sonar NbxZPo9_
Preparing the "docker" executor
00:04
Using Docker executor with image sonarsource/sonar-scanner-cli:latest ...
Pulling docker image sonarsource/sonar-scanner-cli:latest ...
Using docker image sha256:91f49dbbfdf0d0828fce18b2031ee62a4e7d84566869ecfaf8882709285f2ffb for sonarsource/sonar-scanner-cli:latest with digest sonarsource/sonar-scanner-cli@sha256:5b09af200f24ea231dedef48c0106db817088ccb5466742c60130a1814b16598 ...
Preparing environment
00:17
Running on runner-nbxzpo9-project-887-concurrent-1 via gitlab-runner...
Getting source from Git repository
00:03
Fetching changes...
Reinitialized existing Git repository in /builds/clients/parent/parent/.git/
Checking out f1073c91 as refs/merge-requests/2/head...
Updating/initializing submodules recursively...
Synchronizing submodule url for 'code'
Cloning into '/builds/clients/parent/parent/code'...
error: cannot run ssh: No such file or directory
fatal: unable to fork
fatal: clone of 'git@gitlab.my-domain.net:clients/parent/code' into submodule path '/builds/clients/parent/parent/code' failed
Failed to clone 'code'. Retry scheduled
Cloning into '/builds/clients/parent/parent/code'...
error: cannot run ssh: No such file or directory
fatal: unable to fork
fatal: clone of 'git@gitlab.my-domain.net:clients/parent/code' into submodule path '/builds/clients/parent/parent/code' failed
Failed to clone 'code' a second time, aborting
Cleaning up file based variables
00:03
ERROR: Job failed: exit code 1
- what have you tried so far to achieve this
I’ve firstly tested it well on a repository without any submodule in it, working like a charm, perhaps i can’t get it working on a submodule in a repository.
I also searched for topics on this, but i wasn’t able to find any relevant one, maybe i’ve missed something.
I’m a bit lost, as i’m fairly new to sonar, if someone has any advice…
Thanks a lot by the way if someone sees what’s wrong here.
Happy coding,