Getting up and running with a simple setup of Jenkins which will enable us to develop pipelines and pipeline libraries.
Workshop participants should come with this setup up and running on their laptops, so we can focus on pipeline
it's different features / options.
Instead of explaining all the things related to a Jenkins setup (plugins mainly), we will be using a paradigm Jenkins
supports which is basically using a bunch of groovy scripts to setup our environment.
My bloody Jenkins us written in
In order to be able to learn the pipeline we assume you will have a:
- Jenkins instance,
- A git repository with a Dockerfile
- An ECR / DockerHub account so we can push the image there once were done ...
This example will:
- setup a Jenkins instance
- Configure it via a config.yaml file
- Setup Docker as a
build cloud provider
to Jenkins - Instantiate a seed job
- git (cli installed on laptop)
- A GitHub account
- Docker (cli installed on laptop and run as daemon or connected to remote Docker server)
- docker-compose (cli installed on laptop)
- A Docker hub account (https://hub.docker.com/)
- A local clone of this repository (for the template files in it), which will be your workspace for this workshop.
- A forked clone of the https://github.com/shelleg/jenkins-pipeline-workshop-library repository.
- A forked clone of the https://github.com/shelleg/docker-gitbook repository.
cp config.yml.template config.yml
gitsshkey:
type: sshkey
description: gitsshkey
username: < github username >
passphrase: < your ssh key passphrase if no empty >
privatekey: |
-----BEGIN RSA PRIVATE KEY-----
your ssh should be here, with all lines idented to the left as this line is ...
dockerHub:
type: userpass
username: <dockerhub username>
password: <dockerhub password>
4. fork the docker-gitbook repository and set the config.yml to use it instead of the original docker-gitbook repository **
seed_jobs:
gitbook-docker-jenkins-pipeline-workshop:
source:
remote: [email protected]:<github-user>/docker-gitbook.git
branch: 'master'
credentialsId: gitsshkey
triggers:
pollScm: '* * * * *'
pipeline: jenkinsfile
executeWhen: never
5. fork the jenkins-pipeline-workshop-library repository and set the config.yml to use it instead of the original jenkins-pipeline-workshop-library repository **
pipeline_libraries:
jenkins-pipeline-workshop-library:
source:
remote: [email protected]:<github-user>/jenkins-pipeline-workshop-library.git
credentialsId: gitsshkey
defaultVersion: master
implicit: false
allowVersionOverride: true
includeInChangesets: true
cp docker-compose.yml.template docker-compose.yml
At this stage run:
. ./jenkins_server.sh start
Please note: if it's the first time running my bloody jenkins it will take time to download the image, + perform a reload to Jenkins.
Browse to http://localhost:8080 and login as 'admin' user (password is in the config.yml file). After the server is loaded OK (after restart once for plugins update), a first build should start running.
Once done you should have something like the following:
The main task in the workshop is to convert the simple Jenkins Pipeline to a Pipeline that uses a shared library with Steps and complete-flow class.