Jenkins Build EC2 Ubuntu
lets try same on Ubuntu
Last updated
lets try same on Ubuntu
Last updated
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
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:
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.
Add the Jenkins Debian repository.
Import the GPG keys of the Jenkins repository using the following wget
command:
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:
Install Jenkins.
Once the Jenkins repository is enabled, update the apt
package list and install the latest version of Jenkins by typing:
Jenkins service will automatically start after the installation process is complete. You can verify it by printing the service status:
You should see something similar to this:
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:
Verify the change with:
To set up your new Jenkins installation, open your browser, type your domain or IP address followed by port 8080
, http://your_ip_or_domain:8080
and screen similar to the following will be displayed:
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:
Copy the password from your terminal, paste it into the Administrator password field and click Continue
.
Once the plugins are installed, you will be prompted to set up the first admin user. Fill out all required information and click Save and Continue
.
The next page will ask you to set the URL for your Jenkins instance. The field will be populated with an automatically generated URL.
Confirm the URL by clicking on the Save and Finish
button and the setup process will be completed.
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
At the Jenkins home page on the left menu select Manage Jenkins -> Manage Plugins select the tab Available and search for the following plugins:
Blue Ocean - New Jenkins UI
Pipeline AWS - AWS Integration
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.
Use LTS Release : At the last update of this tutorial, Node.js 10.15.3 is the LTS release available.
For this tutorial, I am using the latest current release and added their PPA to my system.
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.
On the next screen, the setup wizard will ask you whether you want to install suggested plugins or you want to select specific plugins. Click on the Install suggested plugins
box, and the installation process will start immediately.
Click on the Start using Jenkins
button and you will be redirected to the Jenkins dashboard logged in as the admin user you have created in one of the previous steps.