Analyzing ant project with sonar ant task and jenkins - java

I am using the sonar ant task jar for sonar analysis so I setup it in the project-properties.xml and create an Ant build step in jenkins. When I build the job, the analysis works fine and I am able to see the results in the sonarqube server, but in jenkins no link to SonarQube is visible.
Do I really need to install the SonarQube plugin for the link to be visible for the job?

See also how to publish sonar result in jenkins server, or do we have sonar-report jenkins plugin
Normally you let SonarQube handle the code analysis on it's own and not by the Ant task (in the Jenkins job).
The Jenkins plug-in is there to trigger Sonar, to get latest sources (from the SCM) and run the analysis.
The results, are then made available on Sonar, but the Jenkins project, will provide a link to the results.
Workaround
There is (for as far as I know) no way to add a link, to an external generated report. What could be done, is add a simple HTML page, with a link to the Sonar server, to the project. And publish that simple HTML page, with the HTML Publisher Plugin.

Related

Automate generating SVN Tags

I'm working on automating SVN Tag generation through JAVA and need some suggestions to start of with. This is how we do it manually - Check out a maven project/plugin from SVN repo and run a set of maven commands (mvn clean test, mvn release:prepare) to generate SVN tags, mvn release:prepare is the final command that would run unit tests, generate the tag and commit it to SVN and I'm working on automating this process.
I had a look at svnkit api which I can make use of to check out a project to the local file system and find a way to run the set of maven commands to generate tag URL, is there a maven JAVA plugin through which I can trigger maven commands? Or is there a much better way to do this other than JAVA?
I did my research on svn kit but could not find any relevant info to automate the maven process, probably I'm missing out on something.
It seems that you are looking for continuous integration.
I would recommend you to evaluate the use of Jenkins, which can be configured to periodically poll changes from SVN and launch a Maven build. Then, if the build succeeded and you decide to release it, you can perform a Maven release from Jenkins, which would take care of invoking the corresponding Maven goals. You can also configure a post-commit hook in SVN in order to launch a build after each commit.

Sonarqube on Jenkins with IVY project

I have a ivy project setup in jenkins, on which I like to run sonarqube analysis.
Unfortunately it is not possible (it seems) to add the sonarqube analysis on the project itself, but I need to create a mirror project (free-style) with sonarqube scanner as only build step.
I also need to set then the basedir not to the mirror project, but to the original one.
All this is a bit unfortunate and I was wondering whether there is another option to run a sonar analysis on an ivy project in jenkins ?
I have Jenkins 2.7.4, Sonarqube plugin 2.4.4
I could achieve my goal with using the PostBuildAction plugin.
This allowed to add the sonarqube-scanner job to be added at the end of the run.

Is there a way to integrate sonarlint plugin in pom.xml

I want to add sonarlint plugin to my project. When I build with maven, the plugin should be automatically enabled without my intervention. Is there a way I could do it?
SonarLint is a local plugin that can be embedded in your IDE.
In the plugin setting you can put the "Automatically trigger analysis" in order to have feedback while writing.
In order to perform continuous integration you should use SonarQube, it is possible to integrate it with Jenkins or Codemagic and also with Maven.
It is possible to add SonarQube to your pull requests as well. You can see the doc here
You can find more information about the difference between SonarLint and SonarQube here

How can I access Jenkins build artifacts from the groovy Postbuild plugin?

Is there a way to read a build artifact file using the Groovy postbuild plugin?
Some context:
I have written some testng tests that are run by maven in Jenkins. Jenkins runs the tests, gives me the test results, etc. However, I have been asked to also store the results in HP's Application Lifeycycle Management (ALM). A coworker provided me with a post-build groovy script that can interface with ALM and store the test results. I have to pass these parameters to that script:
jobname
pass/fail status
test start time
My idea was to store testng-results.xml as an artifact and parse out the results with xmlslurper, but I don't know how to read the artifact from the groovy plugin. From the groovy postbuild plugin page I have gathered that it might also be possible to read the test results directly from the manager.build variable, but I don't have a lot of experience with Jenkins or this plugin and so far I have been unsuccessful.
I'm also open to other approaches as well. The groovy script is running on the Jenkins server, not on the slave node.
In case this is useful for anyone in the future, the solution that I went with was to find the artifact that I was looking for in manager.build.getArtifacts() and join that path with manager.build.getArtifactsDir()

Using the sonar plugin with eclipse

I'm trying to use Sonar to analyse my projects in Eclipse. I am currently using Maven in eclipse. I installed the Sonar Eclipse plugin as described in this link.
But when I try and associate my project with Sonar, I get an error saying:
project with key not found on server.
Am I missing some steps? I started the Sonar Server before connecting to eclipse. But nothing works.
I even tried following this article (Sonar plugin Eclipse) but to no avail.
Please help..The Sonar documentation is not descriptive at all making it very hard for beginners like me to understand.
You can not associate your project in Eclipse if you haven't first analysed it with Sonar (by running "mvn sonar:sonar" on your project).
Once your project has been succesfully analysed and that you can browse it in the Web UI (http://localhost:9000 by default), then you can try to associate your project within Eclipse and this will work.

Categories

Resources