How to run a code analysis locally from the command line using a quality profile on the SonarQube server? - command-line

On my SonarQube server I have 2 quality profiles (1 for C# and 1 for JS).
How to run a code analysis from the command line locally using them (retain them on server, without using tools like SonaLint) or using a gulp task?

take a look at the documentation of sonarqube for analyzing source code ( current link https://docs.sonarqube.org/latest/analysis/overview/) - there you find a lot of useful scanners for different environments and languages.
You just need to configure them properly, but this is also something you can find within the docs of sonarqube.

Use the command line scanner. It will run an analysis locally from your command line.
Make sure, that you set sonar.host.url in sonar-project.properties, so that the correct quality profiles will be taken into account.

Related

Running Alteryx flows from command line

I'm trying to figure out if I can launch a pre-built Alteryx workflow without launching the Designer - and without having Alteryx Server.
I came across a helpful post on Alteryx uses by #Runonthespot that, among other things, addressed running workflows from the command line, but doesn't go into detail. That discussion is here: https://stackoverflow.com/a/30469848/4313331. I don't have the rep to comment on his post and the question is closed.
He writes:
"Flows are runnable from the commandline on a server, and easiest way I've found (besides using Alteryx's own scheduler) is to save as an "App", and then run from the command line using the Alteryx engine executable, passing it parameters via xml file. You can save a sample xml parameter file from your flow by hitting the magic wand button (after saving the flow as a .yxwz (app)) This brings up a panel that lets you set the variables, and that panel has a handy "save" button which generates an xml file in the right format."
So, I'm looking for more info on this process. Is it simply a question of using Alteryx Server? Or is this a more interesting work around?
Thanks.
Yes, you can run a workflow (used generally to refer to a workflow, macro, or analytical app) without launching the Designer. You'll first need to understand how to run the workflow from the command line. The AlteryxEngineCmd.exe executable runs a workflow. It is located in the Alteryx install path in the bin subfolder. Here is where mine is located:
C:\Program Files\Alteryx\bin
It allows an additional parameter of an XML file with interface values. This is documented for analytical apps ONLY though it does work for macros as well. This is based on my extensive use of this undocumented feature.
Below are two examples:
AlteryxEngineCmd.exe MyWorkflow.yxmd
AlteryxEngineCmd.exe MyAnalyticApp.yxwz AppValues.xml
You can see a post here:
Alteryx Command Line Help
I prefer to wrap the command in a batch file and execute that for more control.
Now that you understand how to run the workflow from the command line, you can execute it anytime you want without launching Designer. Furthermore, you can use Windows Scheduler or a third-party tool to run the command or the batch file on a schedule.
Finally, you do need a license which enables API & Command Line w/ Scheduler. This is less expensive than Alteryx Server.
Have you tried C:\Program Files\Alteryx\bin\AlteryxEngineCmd.exe? It doesn't require server.
https://help.alteryx.com/2019.1/Command_Line.htm
If restrained by budget, you don't need a scheduler license (enables the AlteryxEnginecmd.exe), you can use a windows mouse clicker or even Powershell, to run the Designer though, without manual intervention.

How do I analyze .net project from command-line?

1)There are couple of ways to analyze .net projects like SonarQube.Scanner.MSBuild or sonar-runner or sonar-scanner you can use from command line.
2)I had started using sonar-runner and it worked fine initially for C# and
javascript running analysis twice - one for C# and one for javascript.
3)Now when I'm running analyis for javascript project(with jquery,require.js,
bootstrape.js files) it throws an error - "parser error", "Error during sonar runner execution. Unable to execute sonar. Caused by: Java heap space". I tried increasing heap size in sonar.properties file but didn't help.
4)So I started analyzing projects using SonarQube.Scanner.MSBuild it worked but here you don't have option to specify language(or I don't know the option to specify) and due to this I'm not able to run analysis for languages(PL/SQL,Swift for which I have licence keys) other than C#,javascript.
Could anyone specify best way to analyse project for different languages from command-line.
1) SonarQube Scanner for MSBuild is recommended for the analysis of .NET projects. Why? The analysis configuration for such a project is extremely difficult to write correctly by hand, and the Scanner for MSBuild takes care of all the details for you
2) Yay.
3) By the time the scanner reads your properties file, the process has already been started and its heap space set. You need to set that new value before the process starts: on the command line or in the environment
4) You have projects that contain C#, JavaScript, PL/SQL, and Swift?! If the answer were "no", I'd advise you to use the right tool for the job, and analyze your .NET projects with the SonarQube Scanner for MSBuild, and the other projects with the plain/default SonarQube Scanner. Since I know from the comments the answer is "yes" then I'll advise you to stick with the SonarQube Scanner for MSBuild for the reasons cited in #1.

Visual Studio Online / Azure stopping and starting web applications using Powershell

I'm using Visual Studio Online's build tools to deploy web applications from a single solution. I've occasionally been running into file locking issues.
Error: Web Deploy cannot modify the file 'Microsoft.CodeAnalysis.CSharp.dll' on the destination because it is locked by an external process.
After some Googling, I believe the "fix" is to stop the web applications before deployment on Azure and start it back up after. Sounds legit.
However, there does not seem to be a straight forward way to do this directly on VSO's build definitions. I've created an "Azure Powershell" build task, but it wants a PS1 file from the repository. It doesn't seem to let me just run Azure Powershell commands (e.g. Stop-AzureWebsite) from here. My team has created a work-around where we have a "run.ps1" that just executes the command you pass as a parameter, but none of us are satisfied by that.
What are we missing? There has got to be an easier way to do this without having a PS1 script checked into source control.
I solved this by installing Azure App Services - Start and Stop extension from Visual Studio Marketplace.
When installed, it will allow you to wrap the Deploy Website to Azure task in your Release definition with Azure AppServices Stop and Azure AppServices Start tasks, effectively eliminating the lock issues.
Check if you are using "/" on the "Web Deploy Package" path for folder separators instead of "\".
i.e. change
$(System.DefaultWorkingDirectory)/My Project/drop/MyFolder/MyFile.zip
for
$(System.DefaultWorkingDirectory)\My Project\drop\MyFolder\MyFile.zip
I noticed that was the only difference between the one I was getting the error and the others (the Restart step I added was not helping). Once I modified the path, I got it working.
Sounds crappy, but fixed my issue.
Did you use the Build Deployment Template that sets the correct msbuild parameters for you for your package? You can see how here. I would create a build using that template and see if you have the same issues. If so ping me on Twitter #DonovanBrown and I will see if I can figure what is going on.
As a rule it is good practice to have any scripts or commands required to deploy your software to be checked into source control as part of your build. They can then be easily run repeatedly with little configuration at the build level. This provides consistency and transparency.
Even better is to have deployment scripts output as part of the build and use a Release Management tool to control the actual deployment.
Regardless having configuration as code is a mantra that all Dev and Ops teams should live by.

Jacoco code coverage for remote machine

I tried to find this answer but hardly found it anywhere. I am doing the API testing, In process I need to call the rest API from my local machine. local machine contains the maven project and a framework to call respective rest API.
I need to check the code coverage of remote Rest API and form a report based on the code coverage. please help, how to do that?
Note: I found this link useful but it does not elaborate clearly on what to do?
http://eclemma.org/jacoco/trunk/doc/agent.html
you will probably do a bit of file copying around - depending on the way you run the tests.
JaCoCo runs as a java agent. So you usually add the javaagent parameter as mentioned in the docs you linked to the start script of you application server.
-javaagent:[yourpath/]jacocoagent.jar=[option1]=[value1],[option2]=[value2]
so it would look like:
java -javaagent: -jar myjar.jar
Using tomcat you can add the "-javaagent" part into JAVA_OPTS or CATALINA_OPTS environment variables. Should be similar for other servers.
this will create the jacoco*.exec files. you need to copy those back to your build or CI server to show its results (for ex if you use sonar you need those files before running the sonar reporter). Its important to just include the packages you're interested in.
You can also create one jacoco.exec file per test flavour (jacoco.exec for unit tests, jacoco-it.exec for integration tests, jacoco-at.exec for application tests).
And I would not mix coverage with performance testing - just to mention that too.
There are some examples on stackoverflow for JBoss

Automate deployment of XMLA / documentation on Microsoft.AnalysisServices.Xmla

I'm looking to automate the deployment of XMLA scripts. I've come across an article that gives a small demo, but I'm hoping to find more info.
Specifically, where is the documentation for Microsoft.AnalysisServices.Xmla.XmlaClient and what is the best approach for overridding the database and connection values that are embedded in the XMLA script?
I assume you are just trying to deploy the analysis service cube. This utility has commandline switches and can suport configuration for different targets
Analysis Services Deployment Wizard
If you need to add further customizations, you can always process the resulting xml files with either xslt, powershell, or .net
ascmd.exe can also run xmla scripts:
ascmd.exe commandlline utility
Apparently Microsoft.AnalysisServices.Xmla.XmlaClient is an undocumented library that is actually part of Management Studio and is not re-distributable. I think that using one of Jason's suggestions or the AMO library are your only approaches.