Just a little something to introduce some people to CI/CD with Jenkins
You will need Docker and Docker Compose, check you have both with this command...
docker -v && docker-compose -v
Fork https://github.com/WillGibson/jenkins-workshop to your GitHub account, clone your fork. to your machine and cd jenkins-workshop
.
A hacked together Flask API in a docker container
Build: ./build.sh
Run: ./run.sh
Test: ./dockertest.sh
-
Move into the
jenkins
foldercd jenkins
-
Fire up Jenkins in a Docker container with Docker Compose
docker-compose up
-
Hit http://localhost:8080/ and log in with the admin password you got in the output from the previous command
-
Install suggested plugins
-
Create your admin user and click through past "Save and continue"
-
Click "Create a job"
-
Enter a name, select "Pipeline" and click "OK"
-
General
-
Check "Do not allow concurrent builds"
-
Check "GitHub project" and enter the URL "https://github.com/<your_github_username>/jenkins-workshop"
-
Check "This project is parameterised"
- Select "String parameter"
- Enter "BRANCH" for the name
- Enter "master" as the default
-
-
Build Triggers
- Ignore this for now
-
Advanced Project Options
- Ignore this for now
-
Pipeline
-
Select "Pipeline script from SCM" (Source Code Management)
-
Enter the repository URL "https://github.com/<your_github_username>/jenkins-workshop"
-
Delete the "Branch Specifier" (so it can build any branch based on the branch parameter)
-
Uncheck "Lightweight checkout"
-
-
Click "Save"
-
(Create a Heroku account](https://signup.heroku.com/login)
-
Create a Heroku app
-
Set the stack of your app to container
heroku stack:set container
-
Connect the app to your Git repository
-
Create a deploy key
cd .ssh
ssh-keygen -t rsa -b 4096 -C "[email protected]"
cd ../
-
Add the deploy key to you GitHub repo with write access
-
Log into the jenkins container
docker exec -it jenkins_workshop /bin/bash
-
Run the Jenkins container in the background
docker-compose up -d
-
Stop the Jenkins container if you ran it in the background
docker-compose down