Closed gudge25 closed 6 years ago
You need a sonar-project.properties
file, with the sonar.projectKey
set, among others. Here's an example sonar-project.properties
file:
# sonar project id
sonar.projectKey=YOUR_SONAR_PROJECT_KEY_ID
# main language to be analyzed
sonar.language=php
# included folders
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=config, plugins, src
# excluded folders
sonar.exclusions=plugins/**/tests/**, src/Console/Installer.php, plugins/**/config/**, config/Migrations/**
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
# Set gitlab analysis to exit instead of notifying via commit message
sonar.gitlab.failure_notification_mode=exit-code
You can see more information about this file in: https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner
Please, don't close the issue as we'll try to add a note about this file our readme file.
Thanks for reply i create sonar-project.properties file Picture (dev) http://imgur.com/UjHFgpXl.png
# sonar project id
sonar.projectKey=Krusher
# main language to be analyzed
sonar.language=JavaScript
# included folders
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# Since SonarQube 4.2, this property is optional if sonar.modules is set.
# If not set, SonarQube starts looking for source code from the directory containing
# the sonar-project.properties file.
sonar.sources=config, plugins, src
# excluded folders
sonar.exclusions=plugins/**/tests/**, src/Console/Installer.php, plugins/**/config/**, config/Migrations/**
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
# Set gitlab analysis to exit instead of notifying via commit message
sonar.gitlab.failure_notification_mode=exit-code
BUT STILL the same issue
Cloning repository...
Cloning into '/builds/satskiy.a/KRUSHER'...
Checking out 15883a03 as dev...
Skipping Git submodules setup
$ unset CI_BUILD_REF && /usr/bin/sonar-scanner-run.sh
INFO: Scanner configuration file: /sonar-scanner-3.0.3.778/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_131 Oracle Corporation (64-bit)
INFO: Linux 4.11.12-coreos-r1 amd64
INFO: User cache: /root/.sonar/cache
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=722ms
INFO: User cache: /root/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=176ms
INFO: Download sonar-flex-plugin-2.3.jar
INFO: Download sonar-scm-git-plugin-1.2.jar
INFO: Download sonar-gitlab-plugin-2.1.0.jar
INFO: Download sonar-l10n-ru-plugin-1.6.jar
INFO: Download sonar-scm-svn-plugin-1.5.0.715.jar
INFO: Download sonar-javascript-plugin-3.2.0.5506.jar
INFO: Download sonar-java-plugin-4.15.0.12310.jar
INFO: SonarQube server 6.6.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 8.319s
INFO: Final Memory: 45M/178M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.sources
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Maybe wrong place ? Thanks
Your runner is not taking the sonar-project.properties
. Take a look to the line which says:
INFO: Scanner configuration file: /sonar-scanner-3.0.3.778/conf/sonar-scanner.properties
Now take a look to the first comment you wrote. Both have exactly the same path, so, obviously, your runner is not taking the sonar-project.properties
file.
Is that file added to the root of the project, commited, and pushed?
yes check a picture http://imgur.com/UjHFgpXl.png
Please, paste here how have you configured the runner in .gitlab-ci.yml
(replace any sensible information with ** if required).
stages:
- analysis
sonarqube:
stage: analysis
image: ciricihq/gitlab-sonar-scanner
variables:
SONAR_URL: "https://www.krusher.duckdns.org"
SONAR_PROJECT_VERSION: "$CI_BUILD_ID"
SONAR_ANALYSIS_MODE: "issues"
script:
- /usr/bin/sonar-scanner-run.sh
sonarqube-reports:
stage: analysis
image: ciricihq/gitlab-sonar-scanner
variables:
SONAR_URL: "https://www.krusher.duckdns.org"
SONAR_PROJECT_VERSION: "$CI_BUILD_ID"
SONAR_ANALYSIS_MODE: "publish"
script:
- unset CI_BUILD_REF && /usr/bin/sonar-scanner-run.sh
# must be unique in a given SonarQube instance
sonar.projectKey=Krusher
# this is the name and version displayed in the SonarQube UI. Was mandatory prior to SonarQube 6.1.
sonar.projectName=Webfax
sonar.projectVersion=1.0
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
# This property is optional if sonar.modules is set.
sonar.sources=.
# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
working exammple!!!!
What do you mean with "working example"? Did you finally got it working?
Currently available under the develop
docker tag.