Help Center/ Elastic Cloud Server/ Best Practices/ Setting Up an Application/ Installing and Deploying Jenkins on an ECS
Updated on 2025-09-23 GMT+08:00

Installing and Deploying Jenkins on an ECS

Overview

Jenkins is an open-source automation server. It helps automate the operations related to building, test, and deployment in software development, and promotes continuous integration and continuous delivery (CI/CD). Jenkins is indeed a server-based system that can be deployed and run within a Servlet container such as Apache Tomcat.

Jenkins has a series of excellent features, which are worth adding to your tools. The features include:

  • Easy to use
  • Simple and intuitive user interface
  • Extremely flexible and easy to adapt to your needs
  • 1,000+ plug-ins available for communication, integration, and test with various external applications. If a plug-in is unavailable, you can easily create one.
  • Simple configuration supported on the web-based GUI. This accelerates task creation, improves configuration consistency, and reduces maintenance costs.
  • Cross-OS scripting
  • Compatible with most major platforms because Jenkins is written in Java.

Preparations

  • Before installing Jenkins, purchase an ECS (recommended configuration: 4 GiB+ memory and 40 GiB+ disk size) running CentOS 7.6. Bind an EIP to the ECS.
  • After the ECS is purchased, add the inbound rule listed in the following table to the security group which the ECS belongs to. For details, see Adding a Security Group Rule.

    Direction

    Priority

    Action

    Type

    Protocol & Port

    Source

    Inbound

    1

    Allow

    IPv4

    TCP: 8080

    0.0.0.0/0

Resource Planning

Table 1 lists the resource configuration and software versions used in this practice. The commands and parameters may vary according to the hardware specifications or software versions you would use.

Table 1 Resources and costs

Resource

Description

Cost

VPC

VPC CIDR block: 192.168.0.0/16

Free

VPC subnet

  • AZ: AZ1
  • CIDR block: 192.168.0.0/24

Free

ECS

  • Billing mode: Yearly/Monthly
  • AZ: AZ1
  • Flavor: c9.large.4
  • Image: CentOS 7.6 64bit
  • System disk: 40 GiB
  • EIP: Auto assign
  • EIP type: Dynamic BGP
  • Billed by: Traffic
  • Bandwidth: 5 Mbit/s

The following resources generate costs:

  • Cloud servers
  • EVS disks
  • EIP

For billing details, see Billing Modes.

JDK

A Java development tool software.

Free

Jenkins

A continuous integration tool developed based on Java to monitor continuous and repeated work.

Download URL:

https://repo.huaweicloud.com/jenkins/redhat-stable/jenkins-2.361.1-1.1.noarch.rpm

Free

Procedure

  1. Remotely log in to the purchased ECS.
  2. Install JDK.

    To ensure compatibility with Jenkins, install OpenJDK 11 (view supported Java versions).

    1. Run the following command to check the available versions:
      yum -y list java*
    2. Install JDK 11.
      yum install java-11-openjdk* -y
    3. Check whether the installation is successful.
      java -version

  3. Install Jenkins.

    1. Install Jenkins.
      wget https://repo.huaweicloud.com/jenkins/redhat-stable/jenkins-2.361.1-1.1.noarch.rpm
      rpm -ivh jenkins-2.361.1-1.1.noarch.rpm
    2. Edit the Jenkins file.
      vim /etc/sysconfig/jenkins
      #Port
      JENKINS_PORT="8080"
      #Modify the user
      $JENKINS_USER="root"
    3. Start Jenkins and check its status.
      systemctl start jenkins
      systemctl status jenkins

  4. Unlock Jenkins.

    1. In the address bar of your local browser, enter http:<EIP-bound-to-the-ECS-hosting-Jenkins>:8080. The unlocking page is displayed.

    2. Log in to the ECS.
    3. Obtain the activation password.
      cat /var/lib/jenkins/secrets/initialAdminPassword

    4. On the Unlock Jenkins page, paste this password into the Administrator password field and click Continue.
    5. Install recommended plug-ins and wait until the installation is complete.

    6. After the installation is complete, set the first administrator account as prompted. Enter the username and password and click Save and Finish.

    7. On the instance configuration page, confirm the server domain name or IP address in the Jenkins URL, and click Save and Finish.

      The Jenkins URL is the root URL for providing absolute path links for Jenkins resources.

    8. Click Start Using Jenkins. The Jenkins homepage is displayed.

Verification

Single Job

  1. Choose New item, select Freestyle Project, click OK.
  2. In Build Steps, select Execute shell, enter echo hello world; exit, and click OK.

  3. Click Build Now.
  4. Wait until the execution of build task in the lower left corner is complete. Click Console Output, you can see the job is finished and hello world is displayed.

Multiple Jobs

  1. On the plug-in management page, search for the MultiJob plug-in and install it.
    • After the plug-in is installed, you need to restart Jenkins for the plug-in to take effect. Select Download now and install after restart.

    • After Jenkins is restarted, check whether the MultiJob plug-in takes effect on the installed plug-ins page.

  2. Click New item, select MultiJob Project, and click OK.

    Before creating a MultiJob project, you need to create three jobs.

  3. In Build Steps, select MultiJob Phase.

  4. Add three jobs as follows:

  5. Save the settings. The jobs are added.
  6. Click Build Now. The three jobs are successfully built in sequence.