SonarQube Local Analysis - specify properties file - sonarqube

I'm trying to run the analysis locally using Sonar-Scanner 2.6 pointing to SonarQube 5.4. The local solution folder contains the sonar-project.properties file used in the cloud analysis.
I am trying to create the properties file to be used locally, that is separate from the global sonar-project.properties file. This is the command that I ran:
sonar-scanner -D project.settings=sonar-project-local.properties
Expected behavior: Of the two files (sonar-project.properties and sonar-project-local.properties), sonar-scanner would choose the local one.
Observed behavior: If the file sonar-project.properties exists, sonar-scanner uses the global one and ignores the local one.
If I remove (rename) the global file from the directory, then the local file is recognized, and behavior is as expected.
Is this a bug? What is the way to solve this issue without messing with the global properties file?

Generally the answer would be the space in your command. So, not
-D project.settings=...
but
-Dproject.settings=...
But that property was dropped. You'll just need to shuffle the properties files in/out of the "correct" name.

Related

specify source files when using snakemake remote prefix

From the docs:
https://snakemake.readthedocs.io/en/stable/executable.html
Currently, this mode requires that the Snakemake workflow is stored in a git repository. Snakemake uses git to query necessary source files (the Snakefile, scripts, config, …) for workflow execution and encodes them into the kubernetes job.
However, what is not clear to me is how to specify source files as stated. srcdir returns the absolute path with the specified prefix prepended.
Could someone please point me to the relevant area of the docs please!
Thanks
I haven't worked with kubernetics and Snakemake, but I am assuming using the 'default' structure should work. You can easily generate this structure with the snakemake cookiecutter repo:
https://github.com/snakemake-workflows/cookiecutter-snakemake-workflow
Just make sure cookiecutter is installed and you can run this on the command-line:
cookiecutter https://github.com/snakemake-workflows/cookiecutter-snakemake-workflow
Or you can always just take a look at where files are stored in that repo and copy the structure.

Dynamically get JAR filename in DockerFile

I am new to Docker. I am using spring boot and when we build the project using maven, it will create jar file like app-.jar and then I am coping this jar file using ADD command in DockerFile. Now If I change the version number in pom.xml, then I need to manually update the JAR file name in DockerFile.
Is there anyway by which I can dynamically get the version number which is in the pom.xml and update the JAR file name automatically in the DockerFile?
Instead of copying the jar file inside the dockerfile, you can mount the folder in which jar is created. And you will not be needed to be worried with the filename.
What you want can be done using environment variables. You can create an --env-file and keep your version number there. And inside dockerfile, refer to value of variable declared in env file with {VERSIION}. By following this process, you may want to use this same version in your pom file. For that, take a look at this question.
The answer links environment variables by setting env.path and detailed guide is here.

Unable to get Sonar-Qube to analyze project

I have seen the other 2 appends and added sonar.languages=COBOL to my sonar-project.properties file to no avail.
I think it's basically more a case of not understanding the documentation (or the latter never having been "idiot tested"").
My problem is as follows. My properties file contains the following entries:-
# sonar.sources=../../mfuser/seb/source/
sonar.sources=C:/mfuser/SEB/Source
sonar.cobol.file.suffixes=cbl,cpy
sonar.cobol.copy.suffixes=cpy
#
sonar.languages=COBOL
When I run the sonar-scanner bat file, I'm seeing output like this:-
WARN File C:\mfuser\seb\source\vvira20.cbl is ignored. It is not located in module basedir c:\sonar-scanner\bin
To me this gives the impression that I can point to the directory containing my COBOL code, but at the same time the actual code HAS to be in c:\sonar-scanner\bin. Surely, that can't be the case? If it is, what is the point with the sonar.sources entry in the properties file?
In addition, onece I get this working, is there some way of specifying a parm/wild card so as to analyze SPECIFIC files. I tried sonar.sources=C:/mfuser/SEB/Source/vno* but that didn't seem to make any difference.
Thanks
You ran sonar-scanner from its own directory instead of running from the project directory. As the documentation says:
Run the following command from the project base directory
sonar-scanner
This same documentation recommends to create the sonar-project.properties file at the root of the project directory and to set the "sonar.sources" property to a path which is relative to the sonar-project.properties file.
Alternatively, you may want to use the "sonar.projectBaseDir" property. See the documentation for analysis parameters.

How to set path to the file location in the "CSV Data Set Config" if csv.file is located in bitbucket

I want to run Jmeter project in Jenkins. I commited project.jmx and related csv files in bitbucket. How can I set the path to the csv file located in bitbucket
CSV Data Set config will accept
Absolute path (the complete path like c:\path\to\csv\file.csv)
Relative path from the test (csvfolder\csvfile.csv)
csvfolder
csvfile.csv
.jmx
Assuming the 'csvfolder' folder is present where you have .jmx
If your folder structure is as given below,
csvfolder
csvfile
jmxfolder
jmx
then your CSV file path should be ../csvfolder/csvfile
Not sure about you specific combination, but usually if your files are in the same location you can refer to them by name only.
Let's say
%JMETER_HOME%\jmeter -n -t %LOAD_TESTS_RUNNER_%/_warmup.jmx
-Jusers=1 -Jrampup=5 -Jloop=2 -JpathToToken=Token.txt
Token.txt is just located in the same directory as *.jmx file.
Optionally, you could use system variables to contain your paths.
Depending on your Bitbucket underlying repository type you can configure Jenkins job to be triggered by commit using
Jenkins Git Plugin
Jenkins Mercurial Plugin
So you will be able to refer paths to JMeter .jmx and .csv files just using their names. Or if you prefer full paths - you can use WORKSPACE Jenkins variable like:
%WORKSPACE% - for MS Windows Family
$WORKSPACE - for Linux/Unix/MacOSX
See Continuous Integration 101: How to Run JMeter With Jenkins article for more information on running JMeter tests from Jenkins
How to read data from CSV File and run jmx for linux
If my jmx file is login.jmx
my input file is users.csv
what should be the syntax or command in linux

How to make sonar analysis for C++ work?

I'm trying to use sonar for static analysis on a c++ code. I've installed sonar and configured my project (it appears on the localhost sonar page, but i do not see any code violation for the respective code). I have the C++ community plugin installed.
My sonar-project.properties looks like this:
# required metadata
sonar.projectKey=DiceInvaders
sonar.projectName=Dice Invaders
sonar.projectVersion=1.0
# optional description
sonar.projectDescription=DiceInvaders by CS
# path to source directories (required)
sonar.sources=D:\\DiceInvaders\\Code
# path to test source directories (optional)
#sonar.tests=D:\\DiceInvaders\\Code
# path to project binaries (optional), for example directory of Java bytecode
#sonar.binaries=binDir
# optional comma-separated list of paths to libraries. Only path to JAR file is supported.
#sonar.libraries=path/to/library/*.jar,path/to/specific/library/myLibrary.jar,parent/*/*.jar
# The value of the property must be the key of the language.
sonar.language=c++
sonar.exclusions=**/*.ipch, **/**/*.rc
sonar.cxx.cppcheck.path = "C:\Program Files (x86)\Cppcheck\cppcheck.exe"
sonar.cxx.cppcheck.reportPath="D:\DiceInvaders\Code\cppcheck-reports\cppcheck.xml".
# Additional parameters
#sonar.my.property=value
I do not get any error when running sonar-runner from cmd.
If i run manually the cppcheck.exe tool on my project I can find violations. Why don't the violations appear on sonar's page?
Is there something else I should configure, am I doing something wrong?
I was able to make it work by running the cppcheck tool independently before sonnar-runner, and placing the generated xml report in the bin folder of sonnar-runner.
In the sonar-project.properties file I've specified the xml directly:
sonar.cxx.cppcheck.reportPath=cppcheck-result-1.xml
I had a similar problem, which was caused by a whitespace after 'sonar.language=cs'. Be sure that there is a linebreak immediately after 'cxx'. Hope it works.
The language key of the Sonar C++ Community plugin is not 'c++' but 'cxx'. See http://docs.codehaus.org/pages/viewpage.action?pageId=185073817.
So you must replace 'sonar.language=c++' by 'sonar.language=cxx'

Resources