A plugin with a targeted purpose designed to run before sonar code analysis to create, update, and assign a quality gate for code coverage to a project. Having the quality gate in place for your analysis will break your build if it does not meet the criteria supplied by the plugin.
Job is triggered from a pull request (see YAPah Jenkins Plugin), the project will be cloned and built with all the pull requests changes. Gatekeeper creates a sonar project, a quality gate, and assigns the quality gate to that project then the Sonar Qube Analysis plugin will either succeed or fail the build based on the quality gate metrics.
This plugin does not require plugins to function. However, you need to have a working instance of Sonar running to be able to run the plugin.
- SonarQube Plugin (v2.3)
- Build the plugin (mvn package)
- Log into Jenkins
- Click Manage Jenkins
- Click Manage Plugins
- Click Advanced Tab
- Under upload plugin, select the HPI file from the target directory and select upload
- Build the plugin (mvn package)
- Copy GateKeepah.hpi from your target directory into your plugins directory. (Note: One way to find your plugins directory on mac or linux is to run the ps shell command as in ps -ef | grep Jenkins)
- Restart Jenkins
- Go to Manage Jenkins
- Configure System
- GateKeepah
- Fill out Sonar Host, Sonar User Name, Sonar Password, and optionally fill out the Default Quality Gate Name
- Test Connection (even if your password and username are wrong, this may work because of security settings in sonar, make sure to use a sonar-administrator account)
- Add GateKeepah as a build step
- Enter the properties file or supply the properties in the additional properties field
- Save changes
Since some of the tests require an instance of sonar to hit all code paths you need to supply the authentication criteria and host when running the tests. There is also a config.properties file that needs to have seeded data.
mvn clean package -Dusername=username -Dpassword=password -Dhost=http://sonar.host.com:9000