Continuous Integration with Jenkins on Alibaba Cloud

In this tutorial, we’ll show you how to set up, install and run Jenkins, a continuous integration delivery environment, on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu instance.

What Is Alibaba Cloud’s Elastic Compute Service (ECS)?

Alibaba Cloud’s Elastic Compute Service (ECS) is a range of elastic cloud-based server products that are simpler and more efficient to manage than physical servers. You can create instances, add memory and storage, scale up whenever you need to, build out complex and connected VPCs in different regions, and use them as essential components of Alibaba Cloud’s vast range of cloud products and services.

What Is Jenkins?

Jenkins is a continuous integration build tool which builds and releases application code after any change is made to the code and pushed to the code base. Jenkins saves development time by running automated testing against the code at every change pushed to the repos. Nasty bugs are picked up immediately and the whole team is aware of build failures as they happen.

Jenkins is an open source CI tool — just one of a large choice of open source and proprietary continuous integration build tools. You can use Jenkins as a simple CI server, but more often it serves as the central continuous delivery hub for large projects.

Continuous integration tools solve problems associated with fragmented workflow as programmers and developers on large teams make changes to separate parts of the application code at the same time. Unforeseen issues show up incredibly quickly, allowing teams to deal with build failures efficiently and before they are able to cause further issues to the applications as more changes are added.

Jenkins is extensible and offers a wide range of plugins in order for it to integrate with every product in the continuous integration and delivery world.


You will need an Alibaba Cloud account. If you don’t already have one, head over to the Free Trial page to get $300–1200 worth of Alibaba Cloud products to play around with in the Alibaba Cloud Free Trial.

Let’s go ahead and install Jenkins on an Alibaba Cloud Ubuntu ECSs.

Build and Configure an Alibaba Cloud ECS Instance

First, let’s spin up an Alibaba Cloud ECS instance in our favorite region. Click through to the Elastic Compute Service product page.

Image for post

In your favorite region, click Create Instance.

Image for post

Select your Basic Configuration details and click Next: Networking.

Image for post

We picked the latest version of Ubuntu for our operating system.

Image for post

On the Networking page, make sure to assign a public IP address, and open the HTTP and HTTPS ports in the Security Group for the instance.

When you’re ready, click through to System Configurations.

Image for post

In the System Configurations page, set a password for root access, or a key pair.

Image for post

Leave Grouping as it is and click through to Preview.

Image for post

On the Preview page, check all the ECS configuration details, agree to terms, and click Create Instance.

Image for post

You will see a success message. Click back to Console.

Image for post

You will see your instance starting up in the instances list. Make a note of the public IP.

Image for post

When the instance is up and running, you can access it via ssh and do the software installations from the terminal.

Install Java on Ubuntu 18.04

Jenkins runs on Java, so we need to have Java installed. Connect to your instance via ssh.

Image for post

Update the instance.

apt update

Install Java 8.

apt install openjdk-8-jre-headless

Check you have installed Java Runtime Environment correctly.

java -version

Now install the Java Development Kit.

apt install openjdk-8-jdk

Make sure you’ve installed the JDK correctly.

java -version

Now update and upgrade your packages.

apt updateapt upgrade

Set the JAVA_HOME environment variable. First, check the available paths.

update-alternatives --config java

Next, open the environment file and add the path variable.

nano /etc/environmentJAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/"
Image for post

Reload the file to apply the changes.

source /etc/environment

Check the variable is set correctly.


Update the installation for good measure.

apt update

Now we’re ready to install Jenkins.

Install Jenkins on Ubuntu

Connect to your instance via ssh.

Let’s create a non-root user.

adduser jenkins_user

Give the new user administrative sudo privileges

usermod -aG sudo jenkins_user

Now we’ll add a firewall to the instance, enable it, and check the firewall is active.

ufw allow OpenSSH
ufw enable
ufw status

Now we’re ready to install Jenkins. First, add the repository key to the packages.

wget -q -O - | sudo apt-key add –

Append the Debian package repository address to the instance’s sources.list.

sudo sh -c 'echo deb binary/ > /etc/apt/sources.list.d/jenkins.list'

Now update and install Jenkins.

apt update
apt install jenkins

Let’s start the Jenkins service and check its status.

sudo systemctl start jenkinssudo systemctl status jenkins
Image for post

By default, Jenkins runs on port 8080. Open the port with ufw and check status.

sudo ufw allow 8080
Image for post

Check Jenkins logs.

tail -f /var/log/jenkins/jenkins.log
Image for post

Open port 8080 inbound and outbound in the Security Group for the instance.

Image for post

Restart the instance. Once the instance is running again, you will be able to access Jenkins via the public IP and port 8080. Go to a browser window and input the following:

http://<<Public IP Address>>:8080
Image for post

Follow the onscreen instructions to set up Jenkins.

Find the administrator password and enter it — make sure you keep a note of it.

nano /var/lib/Jenkins/secrets/initialAdminPassword
Image for post

We’ll install the suggested plugins.

Image for post

You will see details of the plugin installation process.

Image for post

When completed, you will be asked to set up a Jenkins user, but you can continue as admin.

We continued as the admin user.

Image for post

Now save the Jenkins URL.

Image for post

You can now start using Jenkins.

Image for post

If you see a blank screen, restart Jenkins.

sudo service jenkins stopsudo service jenkins start

Now you can login with the administrator details and start creating jobs.

Image for post
Image for post

Go ahead and set up your project’s releases to be managed by Jenkins.


To summarize, we told you about Alibaba Cloud’s Elastic Compute Service (ECS) and Jenkins continuous integration build tool. We showed you how to create an ECS Ubuntu 18.04 instance, how to login to it with ssh, and how to install Java and Jenkins. Finally, we confirmed that we had installed Jenkins correctly via a browser window and performed the initial set up.

Keep your eye out for more tutorials on Alibaba Cloud’s products and services at


Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store