Detailed installation and use of Jenkins (reproduced)

Operating environment: Windows

1. Environmental preparation

1 Install JDK

  This article uses jdk-8u111-windows-x64.exe;

2 configure tomcat

  This article uses tomcat8, no need to install, just configure JAVA_HOME and JRE_HOME environment variables;

3 install maven

  This article uses maven3.3.9, no need to install;

4 Install Jenkins

  The download address is https://jenkins.io/download/, only the war package is downloaded, as shown below:

 

Put the downloaded jenkins.war into the tomcat/webapps directory.

 

Two, related configuration

1 Log in to http://localhost:8080/jenkins and enter the Jenkins initialization page. The first startup may take a long time, so be patient. After entering successfully, you will see the following screen, open the password file according to the prompt path, and enter the password:

 

After unlocking, it will take a long time to wait, after which the interface as shown in the figure below may appear:

 

It means that the Jenkins plug-in cannot be downloaded. It may be caused by the firewall. The installation of the Jenkins plug-in is very important. If you can't get over the wall, choose Skip Plugin Installations to skip the plug-in installation. Enter the following page and set the login user:

 

2 After the setting is successful, enter the main interface of Jenkins:

 

Click System Management on the upper left side to enter the basic system settings of Jenkins (mainly the following three pieces):

 

3 First enter the "Manage Plug-in" module to install the necessary plug-ins. The following is a list of recommended installations:

 

 

 

 

 

Put the plug-in in the attachment of this article into the Jenkins plug-in storage directory. For example, the plug-in storage directory of this article is: C:\Users\Administrator\.jenkins\plugins (click System Management -> System Settings, and view at the top, as shown below );

 

4 Configure system settings

 

Add encoding global attributes:

 

Increase the email address of the system administrator:

 

Other available default configurations, save and exit.

5 Add global configuration Global ToolConfiguration

 

Configure JDK instead of automatic installation:

 

Configure maven without automatic installation:

 

The above is the system configuration that needs to be set.

 

Three, system deployment

After the system is set up, start adding tasks, select free style for task type:

 

After creation, you can see the following screen on the homepage:

 

You can see the newly created task under the "All" tab, click on the task to enter the task configuration page:

 

Set project notes and construction rules:

 

Configure the source code location for project polling (@HEAD means to build the latest code) and configure the code access password:

 

Configure the build trigger, as shown in the figure below, to start building at 9:30 every night (Cron expression):

 

Add the build step of Invoke top-level Maven targets. The plug-in target is to compile, find compilation bugs, and deploy. In addition, you can also configure to ignore test cases when building:

 

Add post-build operation steps: Publish FindBugs analysis results, used to view the code analysis report of the FindBugs plug-in, this module can adopt the default configuration:

 

Add post-build operation steps: Deploy war/ear to a container, used to deploy the war package generated after the build to the tomcat server, the Contextpath in the figure below is used to configure the project access path, such as /RMS_Server indicates the root access directory of the project It is: http://localhost:8080/RMS_Server, Deploy on failure is used to configure whether to deploy to tomcat when the current build fails, and it is not selected by default:

 

The above is all the configuration of this project. After completion, apply (or save) and exit.

After the configuration is complete, you can start to build, and you can view the bugs analysis information and build history on the left:

 

Click on a build record, as #31 in the above figure, to view the build log, SVN code submission log and bug analysis results:

 

 

 

 

Four, coding issues

Chinese garbled characters may appear when viewing some code files in the FindBugs analysis report, as shown below:

 

 

This is caused by the tomcat coding problem. You can check the tomcat related coding in the system management:

 

 

The main concern is the file.encoding attribute and sun.jnu.encoding attribute, both need to be set to UTF-8 to be compatible with Chinese:

 

 

This can be achieved by adding the set "JAVA_OPTS=-Dfile.encoding=UTF-8-Dsun.jnu.encoding=UTF-8" command in the tomcat configuration file /bin/catalina.bat file, as shown in the following figure:

 

 

After the configuration is complete, restart tomcat, you can see that the encoding has been changed:

 

 

Guess you like

Origin blog.csdn.net/zh127368zh/article/details/85955369