PyLint integration with JenkinsInstalling pylint on Centospip install pylint
Generating a configuration file')
touch pylint.cfg pylint --generate-rcfile > pylint.cfg
After generating the file, it must be placed in the root directory of the project.
Run in Jenkins1. In the Jenkins settings - plug-in management install the “Violations plugin” plug-ins to generate a visual report
2. Create a project (job) with a free configuration
3. In the source control item, insert the link to the repository.
4. At the assembly point, select “Run shell command” or “Execute Shell”. In the input field enter the command:
find /var/lib/jenkins/workspace/$JOB_NAME/<path/to/check> -iname "*.py" | xargs pylint
5. In the post-assembly point, select “Report Violations“
6. Save the project and execute
Fig.1. PyLint checks result
Fig.2. PyLint checks result - continuation 1
Fig.3. Result of performing PyLint checks - continuation 2
Fig.4. PyLint checks result - continuation 3
Fig.5. Result of performing PyLint checks - continuation 4
Fig.6. Result of performing PyLint checks - continuation 5
Integration of SonarQube with JenkinsInstall and configure MySQL for SonarQube: wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm sudo yum update -y sudo yum install mysql-server sudo systemctl start mysqld sudo mysql_secure_installation - enter mysql -u root -p CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE USER 'sonar' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar'; GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
Installing SonarQube on Centos:Download the installation file to / opt cd /opt sudo wget https:
Install unzip and java sudo yum install unzip -y sudo yum install java-1.8.0-openjdk -y
Unzip sonarqube sudo unzip sonarqube-6.0.zip mv sonarqube-6.0 sonarqube
Configuring a configuration file vi /opt/sonarqube/conf/sonar.properties sonar.jdbc.username=sonar sonar.jdbc.password=sonar sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance sonar.web.host=localhost sonar.web.context=/sonar sonar.web.port=9000 http://localhost:9000 sonarqube
Starting SonarQube: cd /opt/sonar/bin/linux-x86-64/ sudo ./sonar.sh start
Setting up SonarQube as a service:Create file
/etc/init.d/sonar
Copy to file contents #!/bin/sh # # rc file for SonarQube # # chkconfig: 345 96 10 # description: SonarQube system (www.sonarsource.org) # ### BEGIN INIT INFO # Provides: sonar # Required-Start: $network # Required-Stop: $network # Default-Start: 3 4 5 # Default-Stop: 0 1 2 6 # Short-Description: SonarQube system (www.sonarsource.org) # Description: SonarQube system (www.sonarsource.org) ### END INIT INFO /usr/bin/sonar $*
Linking to SonarQube sudo ln -s /opt/sonarqube/bin/linux-x86-64/sonar.sh /usr/bin/sonar
Setting permissions and adding to boot sudo chmod 755 /etc/init.d/sonar sudo chkconfig --add sonar
Running sonar sudo service sonar start
Install sonar runner: yum install sonar-runner wget http://repo1.maven.org/maven2/org/codehaus/sonar/runner/sonar-runner-dist/2.4/sonar-runner-dist-2.4.zip unzip sonar-runner-dist-2.4.zip mv sonar-runner-2.4 /opt/sonar-runner export SONAR_RUNNER_HOME=/opt/sonar-runner export PATH=$PATH:$SONAR_RUNNER_HOME/bin
You must create a sonar-project.properties file in the project root. Example of file content:

Run in Jenkins:
1. In the Jenkins settings - manage plug-ins to install the plug-ins “SonarQube Scanner for Jenkins” to generate a visual report
2. Go to “Jenkins Settings” - “System Configuration” - “SonarQube servers” (if this configuration is not present, then Jenkins must be rebooted). Next you need to fill in the configuration fields:
Fig.8. Setting up a SonarQube server in a Jenkins continuous integration system
3. Go to “Jenkins Settings” - “Global Tool Configuration” - “SonarQube Scanner”. Fill in the configuration fields
Fig.9. Configuring the SonarQube scanner in a Jenkins continuous integration system
4. Create a project (job) with a free configuration
5. In the source control item, insert the link to the repository.
6. At the assembly point, select “Execute SonarQube Scanner”
In the “Analysis properties” field enter parameters from the sonar-project.properties file or specify the path to this file.
7. Save the project and run
Fig.10. The result of the work SonarQube
Fig.11. The result of the work SonarQube - continued 1
Following the link from the result of the
localhost : 9000 / sonar / dashboard / index / keystone project execution, you can take a closer look at the keystone code quality review report
Fig.12. Sample SonarQube Generated Report
Fig.13. Sample SonarQube Generated Report - Continued 1