We're transferring our CI stack from a consulting company to in-house. We need to export the SonarQube profiles from the consultant's SQ instance to our corporate instance. We can export the profiles but the consultants created hundreds of custom rules and when we try to import the profile it fails to import the custom rules. We found in the API where you can export the rules to a JSON file, but can't find documentation on how to import them.
Is it possible to import SonarQube rules? What is the best way to go about that?
Referenced documentation:
SQ Docs - Copying Quality Profiles:
https://docs.sonarqube.org/display/SONAR/Quality+Profiles#QualityProfiles-CopyaprofilefromoneSonarQubeinstancetoanother
StackOverflow - How to export Rules:
How to extract or export rules from SonarQube
SQ API - Rules: https://docs.sonarqube.org/pages/viewpage.action?pageId=2392166
Anyone trying to replicate rules from the server on their local setup-
For sonarqube community edition 8.7.1 you can simply export the custom rules as XML files.
Goto
Quality Profiles-> Gear Icon -> Backup
This will get you the custom rule in xml file format.
Then in your local setup goto
Quality Profiles-> Restore(top right corner)- select the XML file you downloaded in the previous step
It is not possible to import/export the logic of those custom rules, only their presence in a profile.
In the case of rules coded in Java, you must make them give you at least the jar containing the rule implementations. Once you install that jar (and restart your server) the rules will be available to you.
In the case of rules written in XPath, you must make them give you their XPath configurations, and you will need to re-create those XPath rules on your side (a tedious process of filling in a form once for each rule).
Related
How can I modify the Unsecure and Secure Configuration in plugin code for step?
For example, I have a plugin and I will send it to my friend. I want this plugin to clean or modify all information that my friend has in his XrmToolBox Plugin Step Secure Configuration field and add mine (for me is necessary to add mine config in this field). Can I do it from code in my plugin?
Let's make the things straight.
CRM Plugin is an executable code logic for extending the platform execution pipeline like do something (ex. Assign/Update) after something (ex. Create/Update) happens.
Plugin registration tool (PRT) is useful for registering the Plugin assembly (dll) & steps to execute per our expectation.
Secure/Unsecure config for Plugin step is just like web.config in our web application. Read more
You want to configure certain key/value pair, for example - some external web service credentials, then put it in secure config of that particular plugin step using PRT, so that you can consume it inside the plugin step code logic.
We will not update the secure config from the plugin code, rather we will just consume it.
If you are shipping your environment plugin steps to your friend environment, then give the plugin assembly & step as a solution package, once the solution is imported in your friend environment - the XrmToolBox PRT will show the changes. Or connect the two environments in different PRT sessions & verify the differences for config merge process.
If you want to develop a console app or something to do the deployment for you, read the below link:
Programatically Updating the Secure Configuration of a Plug-in Step
I am using SONAR-CSS-PLUGIN to check all SCSS file in my repository.
As it comes with default set of 100+ rules, at this moment am not willing to apply all rules in one go as as there is legacy code too and it's reporting many errors.
I would like to incremental by applying a set of rules (lets say 10) everyweek.
I am using TeamCity as build tool.
Here is my TeamCity configuration.
-Dsonar.language=scss
-Dsonar.inclusions=Src/**/*.scss
-Dsonar.css.configPath= wanna give path to .stylelintrc or custom set of rules
-Dsonar.sourceEncoding=UTF-8
%sonar.github.pullRequest%
%sonar.github.repository%
I can not find any documentaion showing how to configure above plugin in TeamCity.
Is this -Dsonar.css.configPath right property??
No matter what path I provide -Dsonar.css.configPath= SomePath It always applies all the rules bydefault.
I would like to apply only some rules for time being.
(For people who may need it in future)
Well, I asked question on their git-hub repository.
Good to know they are responsive.
And the creator says its not possible to point any .stylelintrc at this moment.
Also to apply a set of rules one need to create new Quality Profile and set that as default for respective repository in sonar web interface.
Note: Above option is available only for Administrator access.
See detailed thread HERE
I'm using msdeploy on the command-line to deploy a windows service using the sync verb against dirPath source and destination providers. So far so good.
My project's build assets have per-environment config files, and during deploy to a particular environment I want to rename the targeted environment's config file to the default config file name using a replace rule, but no matter how I engineer my replace rule nothing seems to get me the results I want. I've tried with a number of different configurations of the rule with no luck but the one that seems the most logical is this one:
-replace:objectName=filePath,scopeAttributeName=path,scopeAttributeValue=Service\.Dev\.exe\.config,match=Service\.Dev\.exe\.config,replace=Service.exe.config
If I deploy without the replace rule both Service.Dev.exe.config and Service.exe.config are deployed with the expected respective content. Once I add the replace rule above I get just Service.exe.config and it's got the content of that file from the source, not the content of Service.Dev.exe.config as I am hoping for. If I swap the specifications of the match and replace components (and change regexp <-> plain text accordingly) to arrive at:
-replace:objectName=filePath,scopeAttributeName=path,scopeAttributeValue=Service\.Dev\.exe\.config,match=Service\.exe\.config,replace=Service.Dev.exe.config
I just get Service.Dev.exe.config with the content of Service.exe.config and no Service.exe.config in the destination.
I'm sure I'm missing something obvious, but what is it?
This doesn't directly answer your question but I think its a better solution to your root problem.
The real issue here is config management for different environments. Many developers create different configs for each environment like you do. This approach requires a lot of duplication across your different config files which can easily get out of sync.
The best approach I've found for managing configuration across different environments is WebDeploy Parameterization. It is similar to config transforms in that you have a single base config file that is tweaked, so there is far less duplication. Parameterization however is preferred because it applies the changes at deploy time instead of build time. We use this for 50+ applications with great success.
Here is a blog post with more details - http://www.dotnetcatch.com/2014/09/08/parameterizationpreview-visual-studio-extension/
The match and replace should swap
match=Service.Dev.exe.config,replace=Service\.exe\.config
Is it possible to use a rule set defined in .Xml (based on SonarQube- und FindBugs rules) and run it without setting up a SonarQube server.
I want to use SonarLint in Eclipse for some Java projects with only the input of the rule set i get forwarded from other projects of the company.
You can use SonarLint standalone - in which case you will get the default, non-editable rule set - or connected to your SonarQube server - in which case you will get the rules in the profile that's applied to your project.
There is no middle ground where you could feed a list of rules in standalone mode.
I am using SonarQube 5.1.2. I have created many custom rules using Rule Templates for quality profiles of both Java (plugin version 3.13.1) and C# (4.3) languages. I wanted to replicate this SonarQube instance onto a new server and hence did a Backup of the quality profiles and performed 'Restore Profile' on the new SonarQube server.
Strangely, all the custom rules are not imported on to the new SonarQube instance. Why is it so? What should I do to import the custom rules onto new SonarQube instance?
You're looking for SONAR-5366
Make it possible to back up and restore customizations of rules, which is not yet implemented, unfortunately.