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

Installing and Deploying Jenkins on an ECS

Preparations

  • Before installing Jenkins, purchase an ECS (recommended configuration: 4 GB+ memory and 40 GB+ 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: c7.large.2
  • 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://pkg.jenkins.io/redhat-stable/jenkins.repo

https://pkg.jenkins.io/redhat-stable/jenkins.io.key

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 view the current JDK version:
      java -version

      If JDK exists and its version is earlier than 11, uninstall the JDK.

      rpm -qa | grep java | xargs rpm -e --nodeps
    2. Install JDK 11.
      yum install -y java-11-openjdk
    3. Restart the ECS.
    4. Check whether the installation is successful.
      java -version

  3. Install Jenkins.

    1. Run the following commands one at a time:
      sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
      sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
      yum install -y jenkins --nogpgcheck
    2. Edit the Jenkins file.
      vim /etc/sysconfig/Jenkins
      #Port
      JENKINS_PORT="8080"
      #Modify the user
      $JENKINS_USER="root"
      #Modify directory permissions
      chown -R root:root /var/lib/jenkins
      chown -R root:root /var/cache/jenkins
      chown -R root:root /var/log/Jenkins
    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 suggested plugins. After the installation is complete, use the admin account to go to the next step.

    6. Save the settings and complete the installation. The Jenkins page 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.