Jenkins Build EC2 Ubuntu

lets try same on Ubuntu

Jenkins is an open source automation server that offers an easy way to set up a continuous integration and continuous delivery (CI/CD) pipeline.

Continuous integration (CI) is a DevOps practice in which team members regularly commit their code changes to the version control repository, after which automated builds and tests are run. Continuous delivery (CD) is a series of practices where code changes are automatically built, tested and deployed to production.

In this tutorial, we will show you how to install Jenkins on an Ubuntu 18.04 machine using the Jenkins Debian package repository.

Although this tutorial is written for Ubuntu 18.04 Bionic Beaver the same steps can be used for Ubuntu 16.04 Xenial Xerus.

Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.

To install Jenkins on your Ubuntu system, follow these steps:

Create EC2 Ubuntu Instance and do ssh there

ssh -i "pemfile.pem" root@ec2-6.6.6.compute-1.amazonaws.com

  1. Install Java on ec2 instance as Jenkins need it

    Since Jenkins is a Java application, the first step is to install Java. Update the package index and install the Java 8 OpenJDK package with the following commands:

    sudo apt updatesudo apt install openjdk-8-jdk

    The current version of Jenkins does not support Java 10 (and Java 11) yet. If you have multiple versions of Java installed on your machine make sure Java 8 is the default Java version.

  2. Add the Jenkins Debian repository.

    Import the GPG keys of the Jenkins repository using the following wget command:

    wget -q -O - https://pkg.jenkins.io/debian/jenkins.io.key | sudo apt-key add -

    The command above should output OK which means that the key has been successfully imported and packages from this repository will be considered trusted.

    Next, add the Jenkins repository to the system with:

    sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  3. Install Jenkins.

    Once the Jenkins repository is enabled, update the apt package list and install the latest version of Jenkins by typing:

    sudo apt updatesudo apt install jenkins

    Jenkins service will automatically start after the installation process is complete. You can verify it by printing the service status:

    systemctl status jenkins

    You should see something similar to this:

    ● jenkins.service - LSB: Start Jenkins at boot time
    Loaded: loaded (/etc/init.d/jenkins; generated)
    Active: active (exited) since Wed 2018-08-22 13:03:08 PDT; 2min 16s ago
        Docs: man:systemd-sysv-generator(8)
        Tasks: 0 (limit: 2319)
    CGroup: /system.slice/jenkins.service

If you are installing Jenkins on a remote Ubuntu server that is protected by a firewall you’ll need to open port 8080. Assuming you are using UFW to manage your firewall, you can open the port with the following command:

sudo ufw allow 8080

Verify the change with:

sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
8080                       ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
8080 (v6)                  ALLOW       Anywhere (v6

During the installation, the Jenkins installer creates an initial 32-character long alphanumeric password. Use the following command to print the password on your terminal:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword
2115173b548f4e99a203ee99a8732a32

At this point, you’ve successfully installed Jenkins on your system.

Lets run the application build using Jenkins CI which is running on EC2 Ubuntu Instance

Install Jenkins Plugins

At the Jenkins home page on the left menu select Manage Jenkins -> Manage Plugins select the tab Available and search for the following plugins:

Let' s Add Node.js also on server

Node.js package is available in LTS release and the current release. It’s your choice to select which version you want to install on the system as per your requirements. Let’s add the PPA to your system to install Nodejs on Ubuntu.

Use Current Release: At te last update of this tutorial, Node.js 12 is the current Node.js release available.

sudo apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -

Use LTS Release : At the last update of this tutorial, Node.js 10.15.3 is the LTS release available.

sudo apt-get install curl python-software-properties
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -

For this tutorial, I am using the latest current release and added their PPA to my system.

Step 2 – Install Node.js on Ubuntu

You can successfully add Node.js PPA to Ubuntu system. Now execute the below command install Node on and Ubuntu using apt-get. This will also install NPM with node.js. This command also installs many other dependent packages on your system.

sudo apt-get install nodejs

Last updated