Overview

Continuing with the DevOps implementation, in the last blog post, we completed the configuration of the runtime environment for the software used in the toolchain. In this blog post, we will focus on the two main software we use: The deployment of Jenkins and SonarQube ona Windows server built the software foundation for subsequent DevOps implementation

Contents

  1. DevOps operations practice – Build environment for.NET applications from scratch
  2. DevOps Operations practices for.NET Applications from scratch – Jenkins & SonarQube Installation and Configuration

Step by Step

preface

In terms of Jenkins and SonarQube versions, I have selected the latest LTS versions, i.e. long term support versions. If you do not have specific requirements, it is recommended that you do not choose too old software versions

Focus on SonarQube versioning. SonarQube supports persistent to a common database (the default is H2) for automated code checks. However, versions after 8.x only support persistence to Oracle, SQL Server, PostgreSQL and, like Gitlab, no MySQL

Therefore, if you need to persist data to the MySQL database, the last available version is 7.7 (elevator direct), and this version only supports MySQL 5.6 and 5.7. Consider carefully whether to use this version because MySQL database is no longer supported

Jenkins

Program installation

Open Jenkins official website, find the download page (www.jenkins.io/download/), select the latest LTS version to download, for Windows platform, you can run it through war package, run it in Docker, and install it through MSI package. Runs as a Windows service

As a service that needs to run continuously, I choose to complete the deployment of the program through MSI

Double-click the MSI installation file to configure the installation path for the software. for such basic software services, it is recommended to keep the default location

Jenkins will be installed as a separate Windows service. If you need to use a domain account or a local account to run the service, you need to configure the account and password

Jenkins uses Port 8080 by default. You can click the Test Port button below to Test whether the Port currently set has been occupied

As mentioned in the previous article, Jenkins was developed based on Java, and during the installation of the software, the installer will bring out the configured Java SDK information by default. Of course, you can also set up different Java SDKS for Jenkins here

After configuring the required operating environment, add port 8080 used by Jenkins service to the firewall whitelist to allow other machines to access the service

When the configuration is complete, click Install and wait for the installation to complete. When the installation wizard prompts that the installation is complete, Jenkins can be accessed through the browser

Basic configuration

Open the browser and follow the prompts on the page. We need to find the password located in the specified path and copy it to the input box on the page to complete Jenkins’ unlock, so as to continue the subsequent operations

After unlocking, Jenkins will prompt you to install some necessary plug-ins. If you fail to install this page due to network problems or do not pop up this page at all, it doesn’t matter, you can manually select the plug-ins to install in the program later

Wait for the plug-in installation to complete or directly skip the plug-in installation and create an administrator account to manage our Jenkins system. Click next and we will be required to configure a Jenkins URL, which will use the default address. It must be noted here that if you adjust the configuration of the URL, You must use the Web server to perform reverse proxy; otherwise, various problems may occur

After clicking save and finish, the installation and configuration of the basic Jenkins operating environment was completed. Of course, in order to meet our requirements, we also need to install various required plug-ins on this basis, so as to realize the construction pipeline to complete the continuous integration function

SonarQube

Program installation

Like Jenkins, SonarQube chose to download the latest LTS version (elevator ride)

SonarQube downloads a package, unzip the package, and go to the bin directory, which lists how to run the program on different operating systems. Since we’re on Windows, select the Windows-x86-64 folder here. Also, as a service that needs to be resident, it is best to run the application as a Windows service

Right-click installntService. bat, select run as administrator, and then run startntService. bat as administrator

Open the browser, SonarQube uses port 9000 by default, wait for a while, if you can see the following page, it means that the application has been successfully installed, click Log in in the upper right corner, enter the default account and password to Log in to the system (the default account and password are admin).

PS: If the 9000 port is occupied, you can go to the sonar. Properties file in the conf file to modify the configuration and restart the service

Data persistence

For automated code checking data, this is of value because the data is currently stored in SonarQube’s built-in H2 database, which is persisted to the SQL Server database for future use

PS: Please pay attention to the database version information supported by SonarQube

To create a new database, you must adjust the collation of the database to CS (case-sensitive) and AS (lodging-sensitive). For example, I chose Chinese_PRC_CS_AS

Once the database is created, you’ll need to execute the following SQL statement to make sure the is_read_COMMITted_SNAPSHOt_ON property of the current library is set to true. Sonar here is the name of my new database

SELECT IS_read_committed_snapshot_on FROM sys.databases WHERE name='sonar'; Is_read_committed_snapshot_on ALTER DATABASE SONAR SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE;Copy the code

After the database configuration is complete, download the Microsoft SQL JDBC Driver 7.2.2 Package, the JDBC Driver of the SQL Server, to the local PC. Select download package here

Unzip the downloaded package, select x64 folder in auth, obtain the 64-bit SQLjdbC_auth. DLL, and copy it to SonarQube. Here I created a new MSSQL folder under the extensions\ jdbC-driver path to store the DLL

After the driver is downloaded, find the sonar.properties file under the conf file, modify the database connection information, restart the SonarQube service, wait for the creation of the database table, well, this process is slow, wait patiently

Just like Jenkins, we can install various plugins to enrich SonarQube. Here we can log in to the system, click on the Administration menu, download the required plugins in the Marketplace. For example, you can download the Chinese language package here. After the restart, the system will become Chinese

Similarly, if the server is not connected to the Internet, we can download the required plug-ins from the Internet, and then put them in the \ Extensions \plugins folder under the program running path, and restart the service

conclusion

Since then, Jenkins and SonarQube have been installed and configured. Of course, in order to meet our requirements, Jenkins will need to install some necessary plug-ins in the actual use. In the next chapter, continuous integration of.NET applications will be completed by connecting with Gitlab

Of the pit

Personal Profile: Born in 1996, born in a fourth-tier city in Anhui province, graduated from Top 10 million universities. .NET programmer, gunslinger, cat. It will begin in December 2016. NET programmer career, Microsoft. NET technology stalwart, aspired to be the cloud cat kid programming for Google the best. NET programmer. Personal blog: yuiter.com blog garden blog: www.cnblogs.com/danvic712