DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Continuous Integration With Jenkins on Alibaba Cloud

Continuous Integration With Jenkins on Alibaba Cloud

See how to set up, install, and run Jenkins, a continuous integration delivery environment, on an Alibaba Cloud Elastic Compute Service (ECS) Ubuntu instance.

Leona Zhang user avatar by
Leona Zhang
·
Mar. 21, 19 · Tutorial
Like (1)
Save
Tweet
Share
12.41K Views

Join the DZone community and get the full member experience.

Join For Free

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 that 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 several 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.

Prerequisites

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 within 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 title

In your favorite region, click Create Instance.

Image title

Select your Basic Configuration details and click Next: Networking.

Image title

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

Image title

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 title

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

Image title

Leave Grouping as it is and click through to Preview.

Image title

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

Image title

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

Image title

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

Image title

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 title

Update the instance.

apt update

Install Java 8.

apt install openjdk-8-jre-headless

Check that 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 update

apt 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/environment

JAVA_HOME="/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/"

Image title

Reload the file to apply the changes.

source /etc/environment

Check that the variable is set correctly.

echo $JAVA_HOME

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 that 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 - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add –

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

sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable 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 jenkins

sudo systemctl status jenkins

Image title

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

sudo ufw allow 8080

Image title

Check Jenkins logs.

tail -f /var/log/jenkins/jenkins.log

Image title

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

Image title

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 title

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 title

We'll install the suggested plugins.

Image title

You will see the details of the plugin installation process.

Image title

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 title

Now save the Jenkins URL.

Image title

You can now start using Jenkins.

Image title

If you see a blank screen, restart Jenkins.

sudo service jenkins stop

sudo service jenkins start

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

Image title

Image title

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

Summary

To summarize, 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.

Continuous Integration/Deployment Alibaba Cloud Jenkins (software) Cloud computing Integration

Published at DZone with permission of Leona Zhang. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • What’s New in Flutter 3.7?
  • Master Spring Boot 3 With GraalVM Native Image
  • DeveloperWeek 2023: The Enterprise Community Sharing Security Best Practices
  • How To Set Up and Run Cypress Test Cases in CI/CD TeamCity

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: