The Blueriq Model Analyzer comprises three components: the Blueriq Sonar Plugin, Blueriq Quality Gate, and Blueriq Sonar Scanner. To analyze your Blueriq models, only the Blueriq Sonar Plugin and Blueriq Quality Gate need to be installed initially. The Blueriq Sonar Scanner is required to execute the analysis and must be accessible in the environment where you plan to perform the analysis.

Installation requirements

All components require Java to be installed in the environment where they will run. You can install Java using a Java Installer, which makes it globally available, or you can extract it to a specific directory. This installation guide covers both options. Ensure you download the correct Java version (32/64-bit). Refer to the Blueriq Model Analyzer Platform Support page for information on which Java version is compatible with your Blueriq Model Analyzer version.

Blueriq Sonar Plugin

The Blueriq Sonar Plugin is an extension for SonarQube that analyzes the Blueriq models created in Blueriq Studio. To use the plugin, it must be placed within a SonarQube instance. This guide provides instructions for installing SonarQube and correctly placing the Blueriq Sonar Plugin in the appropriate directory so that it becomes accessible.

Installing SonarQube

  1. Check the supported SonarQube version listed in the Blueriq Model Analyzer Platform Support.
  2. Download the appropriate SonarQube version from https://www.sonarqube.org/downloads/.
  3. Unzip the downloaded zip-file to the destination directory of your choice. The contents of the unzipped directory should look like this:

Configuring Java

If Java is not globally available on your system, you'll need to set the path to the Java installation directory. This can be done by editing the wrapper.conf file located in the conf directory of your SonarQube installation.

Below is an example of how the wrapper.conf should be configured when your Java installation directory is located at: C:\Program Files\Java\jdk-11.0.2.

wrapper.conf
# Path to JVM executable. By default it must be available in PATH.
# Can be an absolute path, for example:
#wrapper.java.command=/path/to/my/jdk/bin/java
wrapper.java.command=C:/Program Files/Java/jdk-11.0.2/bin/java

...

Installing Blueriq Sonar Plugin in SonarQube

The Blueriq Sonar Plugin called bma-sonar-plugin.jar needs to be placed inside the installation directory of SonarQube. Navigate to the subdirectory extensions/plugins inside the installation directory of SonarQube, and copy the bma-sonar-plugin.jar into the subdirectory.

Only copy the bma-sonar-plugin.jar to extensions/plugins. If any non SonarQube plugin jars are placed into the extensions/plugins directory, Sonarqube will not start.

Running SonarQube

When the Blueriq Sonar Plugin is in place, start the SonarQube service by running the StartSonar.bat in the subdirectory of the bin directory corresponding to your operating system. For instance /sonarqube/bin/windows-x86-x64

Logging in in SonarQube

To proceed you have to login in SonarQube, which by default is available at localhost:9000. An Administrator can manage tokens on a user's behalf via Administration > Security > Users

When installing SonarQube, a default user with Administer System permission is created automatically:

  • Login: admin
  • Password: admin

Adding a license

In SonarQube, go to Administration → Blueriq, and put the content of your license.aql file into the license textbox.
It is also possible to include the license key in the application.properties of the BMA (see also: Configuring Sonar Scanner).

Blueriq Quality Gate

The Blueriq Quality Gate is a SonarQube Quality Gate, more information about quality gates can be found here.

Adding Blueriq Quality Gate

The Blueriq Quality Gate called bma-qualitygate-installer.jar can be run by using java -jar bma-qualitygate-installer.jar. When running this command you will be prompted with several questions.

Prompt

Input

hostnameThe url to your SonarQube instance. This should be either yoururl.here[:PORT] or http[s]://yoururl.here[:PORT]/
usernameA username for a user with the Administer Quality Gates permission. (default: admin)
passwordThe password for the above mentioned user. (default: admin)

Clean install? (y/n)

Decide whether to delete the current quality gate and overwrite it with a new one. If the answer is not "Y", the script will only install missing conditions.

command line arguments

It is possible pass command line arguments into the bma-qualitygate-installer.jar for information see Quality Gate Installer

During the installation of the Blueriq Quality Gate you will be informed of the progress. After the Quality Gate installation is finished, you can verify that the Blueriq Quality Gate is present in SonarQube. This can be done by navigating to the Quality Gates tab in SonarQube.

Blueriq Sonar Scanner

The Blueriq Sonar Scanner is a SonarQube Scanner, which is a tools to analyze your projects. For Blueriq we have introduced our own Blueriq Sonar Scanner, due to implications we cannot provide an analysis using the default SonarQube Scanners. The Blueriq Sonar Scanner is a Spring Boot Java Command Line Interface runner, which can be used to execute the analysis of your Blueriq Models.

Where to place the Sonar Scanner

Commonly a quality analysis is performed on Continuous Integration(CI) Servers like for instance Jenkins. With older versions of the Blueriq Model Analyzer it was possible to use the Maven Sonar Scanner to execute an analysis, and therefor only a connection to a central maven repository had to be setup. From the Blueriq Model Analyzer version 3 or higher you will need to place the Blueriq Sonar Scanner called bma-sonar-scanner.jar on the environment you which to execute the analysis from. 

For example if you want to execute an analysis on your CI Server, you will need to place the bma-sonar-scanner.jar somewhere on the system of your CI Server. If you want to execute an analysis on locally on your own environment, you will need to place the bma-sonar-scanner.jar somewhere on your local environment. 

Performing an Analysis

See the User documentation on how to execute an analysis of your Blueriq Models.

Enforcing the Quality Gate in a Jenkins pipeline

To enforce the Quality Gate in Jenkins you can use the SonarQube Scanner plugin. To configure the BMA you can follow the provided example configuration of this plugin. The only way the BMA configuration deviates from this example is in the way it triggers the analysis.

Instead of using the "sh "mvn clean package sonar:sonar"" command, use the "java -jar  <location on disk>\bma-sonar-scanner.jar" command to trigger the analysis.

It may occur that after the analysis stage, SonarQube needs some time to process the results while Jenkins already proceeds to the Quality Gate stage. It could therefore be useful to add a wait step.

Example pipeline:

pipeline {
        agent none
        stages {
          stage("BMA SonarQube analysis") {
            agent any
            steps {
              withSonarQubeEnv('My SonarQube Server') {
                java -Dspring.config.location=file:C:\bma\application.properties -jar C:\bma\bma-sonar-scanner.jar
              }
            }
          }
          stage("Quality Gate") {
            steps {
              timeout(time: 1, unit: 'HOURS') {
                waitForQualityGate abortPipeline: true
              }
            }
          }
        }
      }



  • No labels