Install Jenkins On Amazon Linux
Install Jenkins
- Create EC2 instance with Amazon Linux 2 AMI
- We will be using open java for our demo, Get latest version from http://openjdk.java.net/install/
yum -y install java-1.8.0-openjdk
- Lets install java and set the java home
java -version find /usr/lib/jvm/java-1.8* | head -n 3 #JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64 export JAVA_HOME PATH=$PATH:$JAVA_HOME # To set it permanently update your .bash_profile source ~/.bash_profile
- Check java version
java -version
- You can install jenkins using the rpm or by setting up the repo. We will setup the repo so that we can update it easily in future.
sudo yum install epel-release -y sudo yum-config-manager --enable epel sudo yum install daemonize java-1.8.0-openjdk-devel -y wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key yum -y install jenkins
- Start Jenkins
# Start jenkins service systemctl start jenkins # Setup Jenkins to start at boot, systemctl enable jenkins
- By default jenkins runs at port 8080, You can access jenkins at
http://YOUR-SERVER-PUBLIC-IP:8080
Configure Jenkins
- The default Username is admin
- Grab the default password
Password Location:/var/lib/jenkins/secrets/initialAdminPassword - Skip Plugin Installation; We can do it later
- Change admin password
Admin > Configure > Password - Configure java path
Manage Jenkins > Global Tool Configuration > JDK - Create another admin user id
Test Jenkins Jobs
- Create “new item”
- Enter an item name – My-First-Project
- Chose Freestyle project
- Under Build section Execute shell : echo “Welcome to Jenkins Demo”
- Save your job
- Build job
- Check “console output”