Install Jenkins Module
This module contains two scripts for working with Jenkins CI server:
install.sh
: This script will install Jenkins on a Linux server. Currently, Ubuntu is supported. This script also installs therun-jenkins
script.run-jenkins
: This script can be used to configure and run Jenkins. You will typically run this script while your server is booting.
Example code
- Check out the jenkins example for working sample code.
- See install.sh and run-jenkins.sh for all options you can pass to these scripts.
Install Jenkins
The easiest way to install and run these scripts is to use the Gruntwork
Installer (make sure to replace VERSION
below with the latest
version from the releases page):
gruntwork-install \
--module-name 'install-jenkins' \
--repo 'https://github.com/gruntwork-io/terraform-aws-ci' \
--tag '<VERSION>' \
--version 2.164.3
The command above will copy install.sh
to your server, run it, install Jenkins 2.164.3, and copy the run-jenkins
script into /usr/local/bin
. We recommend running this command in a Packer template so you
can create an AMI with Jenkins installed. Check out the jenkins example for an example of such a
Packer template.
Run Jenkins
Once you have an AMI with Jenkins installed, you need to deploy it on an EC2 Instance in AWS. The easiest way to do this is with the jenkins-server module. When the EC2 Instance is booting, you should typically do two things in User Data:
-
Mount an EBS volume for the Jenkins home directory. You want to use an EBS volume so that your Jenkins data is persisted even if the EC2 Instance is replaced (e.g., after a crash or upgrade). The
mount-ebs-volume
script in the persistent-ebs-volume module makes it easy to attach and mount a volume. -
Execute the
run-jenkins
script to start Jenkins, set its home directory to the mount point for the EBS volume, and configure it to use a certain amount of memory:run-jenkins \
--memory "1g" \
--jenkins-home "/jenkins"
Check out the jenkins example for an example of such a User Data script.