Tuesday, May 31, 2016

AWS - How to Install Jenkins 2.x on EC2

This blog shows you how to install Jenkins 2.x on a AWS EC2 instance.

OS: Amazon Linux AMI release 2016.03
JAVA: java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Instance Type: c4.xlarge

1. Download and import the RedHat Linux RPM packages repo:
# wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
# rpm --import http://pkg.jenkins-ci.org/redhat/jenkins-ci.org.key
Note: If you've previously imported the key from Jenkins, the "rpm --import" will fail because you already have a key. Please ignore that and move on.


2. Check you have "Jenkins" repo:
# yum repolist | grep jenkins
jenkins                    Jenkins                                           338

3. Install the latest jenkins:
# yum shell
> install jenkins
> transaction list
> transaction solve
> run
> exit

4. Startup Jenkins:
# service jenkins start
Starting Jenkins                                           [  OK  ]

5. Check log file make sure everything looks fine:
# less /var/log/jenkins/jenkins.log

6. Access Jenkins from a web browser:
http://your-jenkins-server.com:8080

7. You can use iptable rules to redirect traffic to port 80:
# iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080

No comments: