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.
Related
What is the difference between IntelliJ, Maven and Gradle build system in IntelliJ IDEA?
Has IntelliJ IDEA its own build system?
In addition, what is the difference between run in IntelliJ and Gradle bootRun?
Build project is IntelliJ's own build-in build mechanism, it simply compiles all modified and dependent files in the project.
However, it's a "plain vanilla" build. It doesnt do fancy things like creating artifacts, deploying to repositories, codegen from a wsdl - etc. That's what we use build automation tools for, and there are 2 of them (maven and gradle) in widsepread use.
Maven and gradle allow developers to set up a custom (and more complex) build configuration.
The maven pom.xml defines lifecycle goals and the gradle build.gradle defines tasks.
Via a plugin architecture, maven / gradle can accomplish almost anything in a build process. Whilst the maven / gradle "run" task can operate similarly to IntelliJ "Build Project", it's not the same thing - in this case the build is instrumented by the build tool (maven or gradle) and can be configured differently, and be part of a more complicated build process.
What is difference build project in IntelliJ and gradle build?
IntelliJ build uses IDE's own jps project model and builder for compiling the java-based projects. Including incremental build support.
With Gradle build it actually uses Gradle to build the project (think Gradle build task).
In addition, What is difference run in IntelliJ and gradle bootRun?
Basically same as above: IntelliJ runner - uses build results of IDE's builder and IDE's own Run/Debug Configuration to launch the application ant tests. With Gradle runner - IDE delegates this to corresponding (bootRun) Gradle task.
See also Configure the build and run actions for additional details.
I tested this locally in my project, using two builds: one using IntelliJ IDEA's "build project" and the second using Gradle's own build command.
Then I checked the contents of the .build directory in my project and found that the former (IntelliJ IDEA's build) produced less files than the latter (Gradle). I think Gradle's build system is more powerful than IntelliJ IDEA's, which is why I prefer to use Gradle in my projects.
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.
Currently, my built structure for a plugin in is a bit messy: I'm using the normal IDEA project file to build the plugin locally. When I push it to the repo and travis-ci is building it, it uses the maven pom.xml because for travis to work, it always has to download the complete IDEA sources.
Although this works, this has several drawbacks:
I need to keep two built mechanisms up to date. This is
When a new IDEA version is out (every few weeks), I need to change the SDK in maven and in my IDEA settings
When I add a new library, change resources, etc. I need to do this for two the two settings as well
I ran into problems when I kept the IDEA Maven plugin turned on because it saw the pom.xml and interfered with my local built. Turning it off means, I cannot download libraries with Maven which has the feature of tracking dependencies.
I saw that Gradle has an 'idea' plugin and after googling, I got the impression that Gradle is the preferred choice these days. I have seen Best way to add Gradle support to IntelliJ IDEA and I'm sure I can use the answers there to turn my pom.xml into a valid build.gradle.
However, maybe someone else has already done this or can provide a better approach. What I'm looking for is a unified way to build my plugin locally and on Travis-CI.
Some Details
For compiling an IDEA plugin, you need its SDK which you can access through an installation of IDEA or a download of the complete package. Locally, I'm using my installation for the SDK. With Travis, my maven built has the rule to download the tar.gz and extract it.
It turns out that in particular for building an IntelliJ plugin, Gradle seems to have many advantages. This is mainly due to the great IntelliJ plugin for Gradle which makes compiling plugins so much easier. With Gradle, I could turn my >220 lines of Maven build into a few lines of easily readable Gradle code. The main advantages are that
It takes care of downloading and using the correct IDEA SDK while you only have to specify the IDEA version.
It can publish your plugin to your Jetbrains repository and make it instantly available to all users
It fixes items in your plugin.xml, e.g. you can use one central version number in gradle.build and it will keep plugin.xml up-to-date or it can include change-notes
It seamlessly integrates with Travis-CI
How to use Gradle with an existing IDEA plugin
Do it manually. It's much easier.
Create an empty build.gradle file
Look at an example and read through the README (there are many build.gradle of projects at the end) to see what each intellij property does.
Adapt it to your plugin by
Setting the intellij.version you want to build against
Setting your intellij.pluginName
Define where your sources and resources are
Define your plugin version
Define a Gradle wrapper that enables people (and Travis) to build your plugin without having Gradle
Create the gradle wrapper scripts with gradle wrapper
Test and fix your build process locally with ./gradlew assemble
If everything works well, you can push build.gradle, gradlew, gradlew.bat and the gradle-folder to your repo.
Building with Travis-CI
For Travis you want to use the gradlew script for building. To do so, you need to make it executable in the travis run. An example can be found here.
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
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.