Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nk-gears/fa982587366bf029f541c9882975a793 to your computer and use it in GitHub Desktop.
Save nk-gears/fa982587366bf029f541c9882975a793 to your computer and use it in GitHub Desktop.
How to set up CI with Jenkins on AWS EC2 (and some notes)

Continuous Integration with Jenkins on Amazon EC2

This documented is a slightly adapted version to this one: https://gist.github.com/jsuwo/9038610 by Jeff Shantz. He has a fantastic video series on setting up Jenkins on AWS EC2 here: https://www.youtube.com/watch?v=1JSOGJQAhtE&feature=youtu.be&ab_channel=JeffShantz

AWS EC2 set-up

  • Choose 1-2GB Ubuntu Server
  • Create new security group and Enable HTTP (& leave SSH open)
  • Launch!
  • Create new key pair (and add alias to ~/.ssh/config)

Initial Setup

Fixing Locales in Ubuntu 13.04 on Amazon EC2

sudo apt-get install language-pack-en

Installing Jenkins

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
echo "deb http://pkg.jenkins-ci.org/debian binary/" | sudo tee -a /etc/apt/sources.list.d/jenkins.list
sudo apt-get update
sudo apt-get install jenkins

Installing and Configuring Apache

Installing Apache

sudo apt-get install apache2
sudo a2enmod proxy
sudo a2enmod proxy_http

/etc/apache2/sites-available/jenkins.conf

<VirtualHost *:80>
	ServerName HOSTNAME
	ProxyRequests Off
	<Proxy *>
		Order deny,allow
		Allow from all
	</Proxy>
	ProxyPreserveHost on
	ProxyPass / http://localhost:8080/
</VirtualHost>

Change the HOSTNAME to the AWS public DNS name

Enabling jenkins.conf

sudo a2ensite jenkins
sudo service apache2 reload

Installing Java / Git / SVN / Ant

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer ant git-core subversion

You can get the path to Java and Ant as follows:

readlink -f /usr/bin/ant
readlink -f /usr/bin/javac

Install PHP & MySQL

sudo apt-get install php5-cli libapache2-mod-php5 
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql php5-curl
sudo apt-get php5-xsl # For phpdox

If you need to upgrade to PHP 5.6:

sudo apt-get remove php5-cli libapache2-mod-php5 php5 php5-xsl php5-cli libapache2-mod-php5
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install php5-cli libapache2-mod-php5 php5 php5-xsl php5-cli libapache2-mod-php5

Node, npm and Grunt-CLI

To get the latest version of node:

curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install nodejs
sudo ln -s /usr/bin/nodejs /usr/bin/node

Install npm and Grunt cli

sudo apt-get install npm
npm install grunt-cli

Other utilities

sudo apt-get install unzip

Other steps

  • Install composer
  • Create a deploy key under jenkins:~/.ssh (/var/lib/jenkins/.ssh/) & add config
  • Install npm, grunt, grunt-cli (?)
  • Install bitbucket plugin and create webhook (-- not working?) - instead do it custom script with token.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment