This is an ansible playbook to install and configure Jenkins-CI.
The playbook will install NGINX, configure SSL, Docker, a local-only SMTP server and Jenkins. It will also install Docker-maintenance cron jobs and Jenkins-backup scripts to S3.
Used in combination with Deis for Docker-based Continuous Delivery of Websites. See also webprod-deis.
-
Add your SSL certificates in
ssl/
folder. Filesssl/ssl.key
andssl/ssl.crt
are needed. These will be copied to your server. You can use a self-signed certificate. Search 'generate self signed SSL certificate` on instructions on how to create one. -
Copy
local_variables-dist.yml
tolocal_variables.yml
and adjust to your preferences. -
Add your host in
hosts
. Examplehosts
[jenkins]
127.0.0.1
-
Run the playbook:
ansible-playbook -i hosts site.yml
-
Yay!
This playbook installs two GitHub plugins, GitHub and GitHub Pull Request Builder. Read the instructions on how to enable these. In some cases, the plugins fail to install their hooks, but you can still add them manually.
For GitHub
- Payload URL:
https://<your_server>/github-webhook/
- Content Type:
x-www-form-urlencoded
- Payload:
Just the push event
For GitHub Pull Request Builder
- Payload URL:
https://<your_server>/ghprbhook/
- Content Type:
x-www-form-urlencoded
- Payload:
Pull Request and Issue Comment
This playbook expects that you use the ThinBackup Jenkins plugin and that you save backups in /var/lib/jenkins/backups
.
In case of a disaster follow these steps:
- Create a new server based on Ubuntu 16.04.
- Run this playbook against the server created in step 1.
- Copy the ThinBackup backups from S3 to the new server under
/var/lib/jenkins/backups
. - Go to your new Jenkins management interface -> Plugins -> Install ThinBackup. Restart Jenkins.
- Configure ThinBackup to store backups in
/var/lib/jenkins/backups
. Restart Jenkins. - ThinBackup Restore should list all your backups. Restore the latest. This should restore all Jenkins jobs and all configurations.
- Run jobs to verify that everything is OK. Drink relaxing tea, you earned it.
Note that environment passwords used in jobs will not be restored and you will have to do this manually.