Huawei Software Development Cloud vs. Jenkins-JavaWeb Project Continuous Deployment

1. Introduction: Introduction to Jenkins

Jenkins is an open source software project. It is a continuous integration tool developed based on Java. It is used to monitor continuous repetitive work. It aims to provide an open and easy-to-use software platform that makes continuous integration and continuous deployment of software possible.

The demo sample in this article is a JavaWeb project with the following environment:

Server: One CentOS 7.3.1611 host

Code management: git

Compile and package: maven

Release deployment: tomcat7

The following operations such as downloading, decompressing, and executing in this experiment are performed in the host /home/centos directory

The traditional working mode needs to complete the following steps by manual operation:

1. Pull the code

2. Compile and package

3. Stop the tomcat service

4. Upload the package to the tomcat container

5. Start the tomcat service

Using Jenkins, the above steps can be completed with one click, and with the corresponding trigger mechanism (scanning code changes or mandatory scheduled tasks), it can achieve complete unattended and automatic completion. Its inner working steps are as follows:

1. Jenkins' trigger scan detects that the code repository has changed or the set task start time is reached

2. Jenkins uses git to pull code from the code repository

3. Jenkins uses maven to compile and package the pulled code

4. Jenkins transfers the packaged war project to the webapps directory of the specified tomcat

5. Jenkins restarts the tomcat service

2. Preparations

Git version control server:

The Git code server used in this experiment has been prepared in advance and can be used directly

Install on CentOS host (if it already exists, it can be ignored):

1. JDK installation

In this experiment, both Tomcat and Jenkins need to rely on JDK, and the latest version of Jenkins needs JDK1.8 version, which is installed with yum

yum install java-1.8.0-openjdk –y

Execute java after installation

-version to confirm, see the version number indicates success

2. Tomcat installation

In this experiment, Tomcat is used to deploy JavaWeb projects, and the Jenkins plug-in currently only supports Tomcat7 version

Download the installation package:

wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz

If the address is invalid, you can go to the official website http://tomcat.apache.org/ to find a new link address

Modify the port:

The default port of Tomcat is 8080. In this experiment, the port of the host has been occupied and modified to 8082.

After decompressing the installation package, edit the server.xml file in the conf directory of the Tomcat directory, and change the 8080 in the following figure to the new port number:

Start and stop the service:

Go to the bin directory in the tomcat directory, execute ./startup to start, visit it, the address:

http://hostIP:8082. The inability to access is basically a firewall problem. If the kitten interface appears, it means that the service is successfully started. If you want to stop the service, you can execute ./shutdown.sh, or you can find the process pid and execute kill -9 pid number.

Solve the slow start of Tomcat :

If you find that Tomcat starts very slowly, you can open the file /jre/lib/security/java.security in the jdk installation path to find the securerandom.source parameter and modify it to

securerandom.source=file:/dev/./urandom

In this experiment, the file path is /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.141-1.b16.el7_3.x86_64/jre/lib/security/java.security

3. Git installation

yum

-y installgit

After installation, execute git --version to confirm, and seeing the version number indicates success

4. Maven installation

yum-y install maven

After installation, execute mvn -v to confirm, and see the version number to indicate success

 

3. Install Jenkins _

Download the package:

wget http://mirrors.jenkins.io/war/latest/jenkins.war

Start the package:

The downloaded Jenkins program war package can be released with Tomcat, or it can be started directly. In this experiment, the Tomcat service is used to publish JavaWeb projects. In order to avoid confusion, direct execution is used to start.

start command

java -jarjenkins.war --httpPort=8081

If you do not write the port number parameter, the default startup port is 8080

The first time you start the console, a password will be generated and copied

Open the access address: http://host IP:8081, the following page appears

Paste the password just now, or follow the prompts to the host

cat /root/.jenkins/secrets/initialAdminPassword to find the password to copy and paste. Come to the following page

This step is to choose recommended installation or custom installation, and then you can change it at any time, click the first one, know what plug-in to use, click the second one, and you can install less packages in this way. The installed plugins are all under /root/.jenkins/plugins/

Select continue as admin directly

Get started, click to enter

Reset admin password:

The account password will be required for future access. In "System Management" - "Manage Users", reset and modify the password of the admin account.

This completes the Jenkins installation and initial login.

At this time, Jenkins is running in the current page process of CentOS. If the current session is closed, the Jenkins service will stop. You can stop the service first and run the following command to start the background:

nohup java -jarjenkins.war --httpPort=8081 &

To stop the service, you can find the process pid number and execute kill-9pid number

Fourth, configure Jenkins

1. Plug-in installation:

(1) Publish container plugins

Select the optional plugin, filter and search for the Deploy to Container Plugin plugin (this supports deploying code to tomcat containers)

Check it, click the button below: Direct installation, this may take a long time, just wait.

(2) Maven project plugin

The steps are the same as above, the plugin name is MavenIntegration plugin

2. System configuration

(1) JDK, the alias is arbitrary, and the path is filled in the jdk location just installed by yum

/usr/lib/jvm/java-1.8.0-openjdk

(2) Git, pay attention to the git location here, which is the address of the executable file (similar to the location of the java executable file under bin in Java). You can view the path through the git --exec-path command. The git installed by yum in this experiment The executable location is /usr/libexec/git-core/git

(3) Maven, select the maven storage location just installed by yum

/usr/share/maven

At this point, the basic configuration of Jenkins is completed.

5. Create tasks

1. Create a new task

2. Configuration tasks

(1) Source code management

Select Git for source code management. At this time, after adding the url, an error will be reported below, showing that you can go to the authentication, and the authentication can be done (this problem is encountered in other installations). If the authentication fails, please download the authentication Github Authentication plugin plugin, this is in the plugin Managed optional plugins to search for installations

(2) Build a trigger

The default is the first option here, other options can be selected according to the actual business,

E.g:

Build periodically: trigger execution periodically

Poll SCM: Periodically scan the code repository, and the source code changes to trigger execution

For the configuration content, you can click the question mark circle at the back to view the description of the filling rules

This experiment is configured to run every five minutes, H/5 * * * *

(3) Post-build operations

This configuration is to deploy the compiled file **/target/intro.war (that is, the war package generated after the JavaWeb project of this experiment is compiled and built) to the remote Tomcat container below; here the username and password of the Containers are the Tomcat administrator Tomcat URL is the ip and port of the remote Tomcat server you need to deploy.

What needs to be set here is the administrator information of Tomcat, modify the tomcat-users.xml file in the conf folder under the Tomcat container, and restart Tomcat after adding the following content:

 

 

 

 

 

So far the task creation configuration is complete

6. View tasks

At this point, you can click "Build Now", or you can wait for the scheduled task to be triggered automatically.

Open the JavaWeb project to verify the address

http://host ip:8082/intro

At this point, the continuous integration deployment environment built with Jenkins has been completed. Now the project personnel only need to focus on program development and submit the written and tested code to the code repository. The subsequent compilation, packaging, uploading, deployment and other work are all done by Jenkins according to the The prior configuration is done automatically.

7. Comparative Analysis with Huawei Software Development Cloud

1. The software is easy to install

Jenkins★★★☆

After the package is downloaded, it can be installed by command or released through a web container. It depends on JDK and requires a host.

Huawei Software Development Cloud★★★★

Cloud service, without any installation and dependencies, out-of-the-box, requires network

2. Tool integration

Jenkins★★☆☆

Relying on plug-ins to call Git, Maven, Ant and other tools, all the tools used need to be installed locally

Huawei Software Development Cloud ★★★★

All tools are built into the cloud service, no need to install, just use it directly

3. Tool extension

Jenkins★★★★

Rich plug-ins, free to choose and use, can support different software environments well

Huawei Software Development Cloud★★☆☆

The types and versions of the integrated tools are relatively fixed and cannot be freely selected

4. The software is easy to use

Jenkins★★★☆

The operation interface is friendly, and each configuration item has icons for description and configuration samples.

Huawei Software Development Cloud★★★☆

There are a lot of help documents and operation videos on the product, with the help of online customer service, to provide technical support from different angles

5. Automatic task function

Jenkins★★★★

Powerful functions, support free configuration at all levels of the month, week, day, hour, and hour

Huawei Software Development Cloud★★☆☆

At present, the pipeline function supports a fixed time per day or a fixed time on certain days of the week, which cannot be configured more freely

6. Message notification mechanism

Jenkins★★★☆

Send email for notification, email content can be configured

Huawei Software Development Cloud ★★★☆

Notification via email and in-site message

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326355432&siteId=291194637