Overview: Jenkins has long been the first choice for smes to build CICD processes due to its open source features and rich plug-in capabilities. However, Jenkins has disadvantages such as high maintenance cost and complex configuration, and cloud efficiency Flow solves these problems well. This paper starts from the scenario of Java application deployment to cloud server (ECS), and compares the two construction and deployment modes of Ali Cloud cloud efficiency pipeline Flow and Jenkins for reference in selection.

With the continuous development of computer technology and business, the scale of enterprise software becomes larger and larger, and the delivery becomes more and more complex. Continuous delivery of DevOps solutions is gaining ground as the preferred development model for enterprise developers.

There are a variety of CICD tools on the market, each with its own characteristics. From the open source local tools Jenkins, TeamCity, to the cloud free tools Travis CI, Github Action, to the current cloud native era focused on Kubernetes ArgoCD, Tekton Pipeline.

Jenkins has long been the first choice for smes to build CICD processes due to its open source features and rich plug-in capabilities. However, Jenkins has disadvantages such as high maintenance cost and complex configuration, and cloud efficiency Flow solves these problems well.

This paper starts from the scenario of Java application deployment to cloud server (ECS), and compares the two construction and deployment modes of Ali Cloud cloud efficiency pipeline Flow and Jenkins for reference in selection.

Demand analysis

Currently we have a repository of Java code, and we need to build the source code, get the build artifacts, and deploy the build artifacts to a cloud server (ECS) group. The process is simple and abstract as follows:

Git repository code.aliyun.com/flow-exampl… The Spring Boot project, for example, requires an operating environment that provides Java and Maven construction instructions for MVN build, and synchronize the generated JAR package to the server group. Perform application startup command (such as/home/admin/app/deploy. Sh restart), started to be used.

Resolution of the process

Environment to prepare

Flow

Flow is a SaaS service, right out of the box. Users only need an Aliyun account to start the journey of continuous delivery.

After logging in ali Cloud account on Flow platform, new assembly line can be established

Jenkins

Jenkins is an open source CI tool that requires users to provide machine resources to deploy Jenkins Master nodes. If you need to access the Jenkins page in a public network environment, expose the access address using the public IP address or elastic IP address. Take an aliyun ECS (Centos 8) as an example, the process of installing Jenkins includes:

# yum install git Java # yum install git Vim like listening on port/etc/sysconfig/Jenkins JENKINS_PORT = "8081" # installation Jenkins sudo wget - O/etc/yum. Repos. D/Jenkins. Repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key sudo dnf install jenkins sudo systemctl start jenkins sudo systemctl enable jenkins systemctl status jenkinsCopy the code

After the Jenkins process is started, you can access the Jenkins page by using the machine IP + port.

Host Group Configuration

We call the concept of the server on which the final Java application runs a host group, which can include N >=1 server.

Flow

The Flow host group supports two types, including Aliyun ECS and Aliyun hosts that can access the public network. Take logging in to ECS under Aliyun account as an example:

A. Access the host group management page

Access host group management in Enterprise Settings

B. Click create button and select Aliyun ECS

C. Create service authorization and select an ECS instance

After the host group is configured, it will be used in pipeline-deployed nodes.

Jenkins

For example, to access the server using the SSH private key, generate a pair of RSA keys on the machine and run the following command: Press Enter

ssh-keygen -t rsa -m PEM
Copy the code

You can view the generated key file in the ~/. SSH directory. Copy the contents of the ID_RSA private key

[root@iZbp1614mku6kuzmrnyi6uZ. SSH]# ls-al total amount 16 DRWX ------ 2 root root 80 May 30 14:26. dr-xr-x--.7 root root 233 May 30 14:43.. -rw------- 1 root root 1574 5月 30 14:26 authorized_keys -rw------- 1 root root 2455 5月 30 14:26 id_rsa-rw-r --r-- 1 root Root 582 May 30 14:26 id_rsa.pub -rw-r--r-- 1 root root 173 May 30 13:55 known_hostsCopy the code

Access Credentials Jenkins added configuration page, such as http://xxxx:8081/credentials/store/system/domain/\_/newCredentials

Access to remote hosts configuration page, such as http://xxxx:8081/configure, select the newly created the credential, connectivity test connection.

At this point, we completed the configuration of a host (note: Jenkins and The Java server are on the same network, so the server does not need to open public network access, otherwise, it needs to apply for the configuration of public network reachable IP). Flow, on the other hand, can send commands through the Aliyun Assistant, reducing the configuration of public IP addresses or elastic EIP addresses.

Build and deploy the configuration

Flow

A. Select Java · Build and deploy to Aliyun ECS/ own host template

B. Add sample code libraries (Java, Spring Boot)

C. Click the Java Build Upload task to select JDK and Maven versions and configure build instructions.

D. In the build upload task, directly enter multiple packaging paths to generate build products, such as Default

E. In the deployment task, select Download Product, select the configured host group, select download product path, execute user, and execute command, and click Save and allow to trigger the pipeline instance to run. (Flow supports deployment policies such as release pause and batch release, see)

F. As can be seen in the build node, Flow uses the maven.aliyun.com/ repository and the M2 cache by default for MVN builds to speed up the build and avoid the time-consuming downloading of jars from the Nexus repository each time.

G. In the build upload step, you can see that the JAR package and deploy.sh package in the workspace after MVN builds are packaged and uploaded to the remote storage.

H. You can download the Default product package directly from the pipeline example page.

I. Click the deployment task to view detailed deployment information, such as deployment time and logs.

Clone Git repo -> Mvn Build -> Deploy To ECS

Jenkins

A. Visit http://xxxx:8081/newJob to create a task

B. Configure the source address of the Git repository

C. Configure MVN execution instructions (in order to facilitate the test process, I use the same machine here as the build and deployment machine for Deploying Jenkins and Java. It is strongly recommended that the production environment isolate Jenkins, application build and deployment machines)

D. save the task allocation, triggers the task to run, visit http://xxxx:8081/job/daily-deploy-test/1/console job log details page, Can see Jenkins will clone code repository to/var/lib/Jenkins/workspace/daily – deploy – test, execute MVN build and deploy. Sh scripts

summary

Clone Git repo -> Mvn Build -> Deploy To ECS

You can see that Flow does a lot of good work in the context of continuous software delivery, allowing users to focus on the business logic itself.

The original link

This article is the original content of Aliyun and shall not be reproduced without permission.