Setting Up Jenkins on Amazon EC2 Ubuntu Instance
We are writing this blog to list down the process of setting up jenkins on Amazon EC2 Ubuntu instance having OS version 18.04.
Pre-requisites :
- 1 AWS EC2 Instance should be up and running
- Make SSH connection with your EC2 instance
Install Java
- Enable ‘Universe’ repository using below command
- sudo add-apt-repository universe
On older versions of Ubuntu you can use below command
sudo add-apt-repository “deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe”
- sudo add-apt-repository universe
- Use below command to install java
- sudo apt install openjdk-8-jdk
- Setup Java_Home using below commands
- Open bashrc file with command
– nano .bashrc
Add below lines at the end your in bashrc file
export JAVA_HOME=/usr
export PATH=$JAVA_HOME/bin:$PATH
- Open bashrc file with command
Install Jenkins
- Add the key using below command in order to use debian package repository of Jenkins
- wget -q -O – https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add –
- Add the following entry in your /etc/apt/sources.list
- sudo sh -c ‘echo deb https://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list’
- Execute below commands
- sudo apt-get update
- sudo apt-get install jenkins
- Open a web browser and enter the url, here you will be asked to enter admin password
- <your_ec2_ip_address>:8080
- Copy the jenkins admin user password using below command, and paste it in the “Administrator Password” section on your web browser
- sudo cat /var/lib/jenkins/secrets/initialAdminPassword
- Continue with the setup and install suggestive plugins by clicking on the button ‘Install suggested plugins’
- Create your first admin user and click on the button ‘Save and Continue’
- Navigate to <your_ec2_ip_address>:8080 in your web browser and login with admin credentials setup in step 7.
!!Your setup is completed!!