|
| 1 | +# Install Jenkins on AWS EC2 |
| 2 | +Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems. As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project. |
| 3 | + |
| 4 | + |
| 5 | +### Prerequisites |
| 6 | +1. EC2 Instance |
| 7 | + - With Internet Access |
| 8 | + - Security Group with Port `8080` open for internet |
| 9 | +1. Java v1.8.x |
| 10 | + |
| 11 | +## Install Java |
| 12 | +1. We will be using open java for our demo, Get the latest version from http://openjdk.java.net/install/ |
| 13 | + ```sh |
| 14 | + yum install java-1.8* |
| 15 | + #yum -y install java-1.8.0-openjdk-devel |
| 16 | + ``` |
| 17 | + |
| 18 | +1. Confirm Java Version and set the java home |
| 19 | + ```sh |
| 20 | + java -version |
| 21 | + find /usr/lib/jvm/java-1.8* | head -n 3 |
| 22 | + JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-<Java version which seen in the above output> |
| 23 | + export JAVA_HOME |
| 24 | + PATH=$PATH:$JAVA_HOME |
| 25 | + # To set it permanently update your .bash_profile |
| 26 | + vi ~/.bash_profile |
| 27 | + ``` |
| 28 | + _The output should be something like this,_ |
| 29 | + ```sh |
| 30 | + [root@~]# java -version |
| 31 | + openjdk version "1.8.0_151" |
| 32 | + OpenJDK Runtime Environment (build 1.8.0_151-b12) |
| 33 | + OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode) |
| 34 | + ``` |
| 35 | + |
| 36 | +## Install Jenkins |
| 37 | + You can install jenkins using the rpm or by setting up the repo. We will set up the repo so that we can update it easily in the future. |
| 38 | +1. Get the latest version of jenkins from https://pkg.jenkins.io/redhat-stable/ and install |
| 39 | + ```sh |
| 40 | + yum -y install wget |
| 41 | + sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo |
| 42 | + sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key |
| 43 | + yum -y install jenkins |
| 44 | + ``` |
| 45 | + |
| 46 | + ### Start Jenkins |
| 47 | + ```sh |
| 48 | + # Start jenkins service |
| 49 | + service jenkins start |
| 50 | + |
| 51 | + # Setup Jenkins to start at boot, |
| 52 | + chkconfig jenkins on |
| 53 | + ``` |
| 54 | + |
| 55 | + ### Accessing Jenkins |
| 56 | + By default jenkins runs at port `8080`, You can access jenkins at |
| 57 | + ```sh |
| 58 | + http://YOUR-SERVER-PUBLIC-IP:8080 |
| 59 | + ``` |
| 60 | + #### Configure Jenkins |
| 61 | +- The default Username is `admin` |
| 62 | +- Grab the default password |
| 63 | +- Password Location:`/var/lib/jenkins/secrets/initialAdminPassword` |
| 64 | +- `Skip` Plugin Installation; _We can do it later_ |
| 65 | +- Change admin password |
| 66 | + - `Admin` > `Configure` > `Password` |
| 67 | +- Configure `java` path |
| 68 | + - `Manage Jenkins` > `Global Tool Configuration` > `JDK` |
| 69 | +- Create another admin user id |
| 70 | + |
| 71 | +### Test Jenkins Jobs |
| 72 | +1. Create “new item” |
| 73 | +1. Enter an item name – `My-First-Project` |
| 74 | + - Chose `Freestyle` project |
| 75 | +1. Under the Build section |
| 76 | + Execute shell: echo "Welcome to Jenkins Demo" |
| 77 | +1. Save your job |
| 78 | +1. Build job |
| 79 | +1. Check "console output" |
| 80 | + |
0 commit comments