Skip to main content
CI Modules 0.59.4Last updated in version 0.58.0

Install Jenkins Module

View Source Release Notes

This module contains two scripts for working with Jenkins CI server:

  1. install.sh: This script will install Jenkins on a Linux server. Currently, Ubuntu is supported. This script also installs the run-jenkins script.
  2. 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

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:

  1. 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.

  2. 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.