-
Notifications
You must be signed in to change notification settings - Fork 37
Jenkins CI Test Slave AMI
Adam Hooper edited this page Nov 24, 2017
·
5 revisions
We run automated tests on as many features as we can.
TODO wipe all this out. Jenkins now works with cloud-init scripts, so we should make this a cloud-init. The only problem: AWS's default 8GB might not be enough space, and I don't know how to increase it.
Normally, each push to master will make Jenkins spin up a test slave to run automated tests.
That slave needs to run something -- an Amazon Machine Image containing an operating system and Jenkins slave.
We try to keep the slave image minimal, so we won't need to change it often. But every once in a while, you may need to change the build environment; and then you'll need to use this guide.
Here's how to create the new AMI:
- Browse to https://cloud-images.ubuntu.com/locator/ec2/ and spin up a "hvm:ssd" instance. (It'll only be up for an hour or two.) Configure security group
jenkins-test-slave
-
ssh -A
into the Jenkins instance, and from there, SSH into your newly-started instance. - Copy/paste this script through SSH:
#!/bin/sh
#
# This *should* be a cloud-init script, but Jenkins' EC2 plugin puts its own
# important variables in user-data, so we can't put a cloud-init script there.
#
# Instead, you'll have to copy/paste this when creating a new AMI.
#
# Steps:
#
# 1. Launch a fairly speedy EC2 instance with Ubuntu 17.04.
# 2. Copy/paste the following commands.
# 3. Create a snapshot, and turn it into an AMI.
export DEBIAN_FRONTEND=noninteractive
# https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu zesty stable"
sudo apt-get -y -q update
sudo apt-get -y -q dist-upgrade
sudo apt-get -y -q install awscli ca-certificates docker-ce unzip python3-pip openjdk-8-jre-headless
sudo pip3 install docker-compose
sudo usermod -G docker ubuntu # make "docker start" work for ubuntu
- "Stop" the instance (in AWS website)
- Create an AMI from the instance, and label it
jenkins-test-slave
- Configure the AMI in Jenkins: log in -> configuration -> system -> AMIS -> AMI ID
- Test the new image by triggering a build in Jenkins. If there's an error, "Start" the instance (in step 4) and iterate, fixing bugs.
- Terminate the instance.