Assumptions:
- You have IAM access to an AWS account, with privileges to deploy and manage resources
- This account is isolated from any customer work
- Your organisation has experience in architecture of solutions on AWS, including VPCs, security groups, bastions, and subnets
- A basic solution architecture for securely running public and private resources in AWS is documented and available to you
- You have some familiarity with the concepts above, and an expert to ask if necessary
Instructions:
- Consult your Cloud Architect and pick an existing VPC in which to deploy Jenkins. We recommend one that already has a bastion set up.
- Note down the security group the bastion belongs to
- Create a security group from the EC2 dashboard in the AWS Management Console.
- Make sure that the security group is in the VPC you will be using.
- Give the security group a “Name” tag with something descriptive in it.
- Add an in bound rule for type SSH and source the bastion security group (start typing the bastion’s security group name into the source, the console will auto-complete).
- Add a second inbound rule with type custom TCP, port 8080, and the bastion security group.
- “Launch Instance” to start up an EC2 (Amazon Linux AMI. Any size will do, I used t2.micro). We recommend a “private-apps” subnet in your VPC. In which case you’ll need to:
- Start the NAT that marshalls traffic in your VPC
- Edit the NAT security group to allow TCP 465 (SMTPS) inbound for all your private-apps subnets (use CIDR notation), and outbound to Anywhere on the same port.
- Start the Bastion
- Connect to the bastion. You can get an RDP connection by clicking Actions->Connect on the EC2-console when the bastion is selected.
- SSH from the bastion to the EC2. Get the EC2’s IP address from the console. Make sure that you have the appropriate PEM/PPK file on the bastion and that it is configured for the SSH session. This step will rely on your knowledge of how security is implemented in this VPC. Once connected, run the following commands:
-
sudo bash
-
yum update
-
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
-
rpm --import http://pkg.jenkins-ci.org/redhat-stable/jenkins-ci.org.key
-
yum install jenkins
-
yum install git
-
service jenkins start
-
chkconfig jenkins on
-
-
- On the bastion, point a browser to http://<IP>:8080 where <IP> is the private IP of your Jenkins EC2
- Click Manage Jenkins
- Click Setup Security
- Click Enable Security
- Select Jenkins’ own user database
- Select Allow users to sign up
- Select Logged-in users can do anything
- Save
-
- Click Create an account
- Fill in Account details to create the account Jenkins will use
- Click Create an account
-
- Click Manage Security then Configure Global Security
- Un-check Allow users to sign up (to lock out changes)
- Save
- Click Manage Security then Configure Global Security
- Click Setup Security
-
- Click Manage Plugins
- Click Available
- Filter by “Git Plugin”
- Choose “Git Plugin”
- Click install without restart
- Wait a minute then check “Restart Jenkins when installation…”
- Wait a minute, then click Jenkins in the top left
- Click Manage Plugins
-
- Log in with the account created above
- Click Manage Jenkins, then Configure System
- Scroll down to “Ant” section
- Click “Add Ant”
- Give Ant a version number that matches the default version (ie. ANT_1_9_5)
- Make sure that “install automatically” is checked (it should default correctly)
- Scroll down to “E-mail Notification” section
- Enter
smtp.gmail.com
into SMTP Server
- Enter
@optimalbi.com
into Default user e-mail suffix
- Click Advanced
- Check Use SMTP Authentication
- Enter your gmail username
- Generate an app-specific password in gmail and enter it here
- Check Use SSL
- Enter
465
into Port
- Enter
jenkins@optimalbi.com
into reply to address
- Check Test configuration by sending test e-mail
- Enter your email into Test e-mail recipient
- Click test configuration (if this fails, double-check your NAT security group settings)
- Enter
- Click Save
- Click Manage Jenkins
Where now?
Why not learn how to configure a Jenkins job?
Used as a references:
http://sanketdangi.com/post/62715793234/install-configure-jenkins-on-amazon-linux
http://www.uvd.co.uk/blog/configuring-jenkins-continuous-integration-server-to-work-with-git/
http://stackoverflow.com/questions/18068358/cant-su-to-user-jenkins-after-installing-jenkins
https://www.safaribooksonline.com/library/view/jenkins-the-definitive/9781449311155/ch08s02.html
http://gistflow.com/posts/822-jenkins-ci-on-ec2-with-e-mail-notifications-and-hipchat-integration-triggered-with-a-commit-to-github-and-finally-pushed-to-heroku