|
| 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 | +### Follow this article in **[Youtube](https://youtu.be/-0dkiteJEuE)** |
| 5 | + |
| 6 | +### Prerequisites |
| 7 | +1. EC2 RHEL 7.x Instance [Get help here](https://www.youtube.com/watch?v=KDtS6BzJo3A) |
| 8 | + - With Internet Access |
| 9 | + - Security Group with Port `8080` open for internet |
| 10 | +1. Java v1.8.x |
| 11 | + |
| 12 | +## Install Java |
| 13 | +We will be using open java for our demo, Get latest version from http://openjdk.java.net/install/ |
| 14 | +```sh |
| 15 | +yum install java-1.8* |
| 16 | +#yum -y install java-1.8.0-openjdk |
| 17 | +``` |
| 18 | + |
| 19 | +### Confirm Java Version |
| 20 | +Lets install java and set the java home |
| 21 | +```sh |
| 22 | +java -version |
| 23 | +find /usr/lib/jvm/java-1.8* | head -n 3 |
| 24 | +#JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64 |
| 25 | +export JAVA_HOME |
| 26 | +PATH=$PATH:$JAVA_HOME |
| 27 | +# To set it permanently update your .bash_profile |
| 28 | +source ~/.bash_profile |
| 29 | +``` |
| 30 | +_The output should be something like this,_ |
| 31 | +``` |
| 32 | +[root@~]# java -version |
| 33 | +openjdk version "1.8.0_151" |
| 34 | +OpenJDK Runtime Environment (build 1.8.0_151-b12) |
| 35 | +OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode) |
| 36 | +``` |
| 37 | + |
| 38 | +## Install Jenkins |
| 39 | +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. |
| 40 | +Get latest version of jenkins from https://pkg.jenkins.io/redhat-stable/ |
| 41 | +```sh |
| 42 | +yum -y install wget |
| 43 | +wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo |
| 44 | +rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key |
| 45 | +yum -y install jenkins |
| 46 | +``` |
| 47 | + |
| 48 | +### Start Jenkins |
| 49 | +```sh |
| 50 | +# Start jenkins service |
| 51 | +systemctl start jenkins |
| 52 | + |
| 53 | +# Setup Jenkins to start at boot, |
| 54 | +systemctl enable jenkins |
| 55 | +``` |
| 56 | + |
| 57 | +#### Accessing Jenkins |
| 58 | +By default jenkins runs at port `8080`, You can access jenkins at |
| 59 | +```sh |
| 60 | +http://YOUR-SERVER-PUBLIC-IP:8080 |
| 61 | +``` |
| 62 | +#### Configure Jenkins |
| 63 | +- The default Username is `admin` |
| 64 | +- Grab the default password |
| 65 | + - Password Location:`/var/lib/jenkins/secrets/initialAdminPassword` |
| 66 | +- `Skip` Plugin Installation; _We can do it later_ |
| 67 | +- Change admin password |
| 68 | + - `Admin` > `Configure` > `Password` |
| 69 | +- Configure `java` path |
| 70 | + - `Manage Jenkins` > `Global Tool Configuration` > `JDK` |
| 71 | +- Create another admin user id |
| 72 | + |
| 73 | +### Test Jenkins Jobs |
| 74 | +1. Create “new item” |
| 75 | +1. Enter an item name – `My-First-Project` |
| 76 | + - Chose `Freestyle` project |
| 77 | +1. Under Build section |
| 78 | + Execute shell : echo "Welcome to Jenkins Demo" |
| 79 | +1. Save your job |
| 80 | +1. Build job |
| 81 | +1. Check "console output" |
| 82 | + |
| 83 | +### Next Step |
| 84 | +- [x] [Configure Users & Groups in Jenkins](https://youtu.be/jZOqcB32dYM) |
| 85 | +- [x] [Secure your Jenkins Server](https://youtu.be/19FmJumnkDc) |
| 86 | +- [x] [Jenkins Plugin Installation](https://youtu.be/p_PqPBbjaZ4) |
| 87 | +- [x] [Jenkins Master-Slave Configuration](https://youtu.be/hwrYURP4O2k) |
| 88 | +- [ ] Setup Jenkins to run inside Tomcat Server |
0 commit comments