Window Builds a Jenkins+SonarQube Continuous Integration Platform from scratch

Windows builds Jenkins + SnoarQube from scratch

This document does not currently contain publishing-related knowledge points.

  • Continuous Integrated Environment: Jenkins
    • Required system environment: java 8 and above, configure java-related environment variables (skipped here)
  • Code hosting: Git 2.22 or gitlab
  • Review tool: SonarQube
    • The tool consists of two parts, SonarQube itself (the review server), and sonar-scanner (the review server)

      The relationship between SonarQube and sonar-scanner is like the relationship between the github website and our local git software

    • snoar-scanner = sonar-runner is the name of the same software in different versions, the online tutorials are basically common

Resource Download

I. Start Jenkins

  • 1. Download the war package for Jenkins
  • 2. Execute java-jar jenkins.war -- httpPort=8089 in the directory where the war package is located
  • 3. Open your browser and enter the web address localhost:8089, then we can see that Jenkins is running

2. Start SonarQube

  • 1. First you need to install the MySql database (in order to configure mysql-related environment variables conveniently, you need to modify your password to enter MySQL for the first time. Skip it here, Baidu Baidu)

    root logs in to mysql to create the sonar database and user authorization.

        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';
        FLUSH PRIVILEGES;
  • 2. Modify sonar.properties under the conf folder under the path

    sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance&useSSL=false
    sonar.jdbc.username=snoar
    sonar.jdbc.password=snoar
    sonar.sourceEncoding=UTF-8
  • 3. You can then start the Snoar server by opening the corresponding StartSnoar.bat in the bin directory.Viewable through browser localhost:9000

    The default SnorQube account password is admin/admin. (Attachment: 5.6 version of SnorQube needs to be localized to find the corresponding tag version released by github to install manually)


3. Configure sonar-scanner (the relationship between SonarQube and sonar-scanner is like the relationship between the github website and our local git software)

  • 1. Configure snoar-scanner.properties in conf in the sonar-scanner directory

    sonar.jdbc.url=jdbc:mysql://172.16.24.12:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
    sonar.jdbc.username=root
    sonar.jdbc.password=root
  • 2. Configure environment variables so that any path under cmd can use the sonar-scanner command

    Entering snoar-scanner-version under cmd indicates success

  • 3. Then we go to the folder of our git project and create sonar-project.properties

    # must be unique in a given SonarQube instance
    sonar.projectKey=my:project
    
    # this is the name displayed in the SonarQube UI
    sonar.projectName=apiautocore
    sonar.projectVersion=1.0
    
    # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
    # Since SonarQube 4.2, this property is optional if sonar.modules is set. 
    # If not set, SonarQube starts looking for source code from the directory containing 
    # the sonar-project.properties file.
    sonar.sources=src
    
    # Encoding of the source code. Default is default system encoding
    sonar.sourceEncoding=UTF-8

  • 4. Since environment variables were previously assigned, this side of the command is sufficient.

  • 5. Then go to the SonarQube server localhost:9000 acceptance result we mentioned earlier.

    The.vue file was not detected here because the plug-in needs to be updated. SonarJS plug-in can be up to version 3.0 with the SonarQube server-side update.

Keywords: PHP JDBC MySQL jenkins git

Added by mattachoo on Thu, 11 Jul 2019 21:17:51 +0300