title |
---|
Jenkins Pipelines |
- Introduction into Jenkins Pipeline and CI/CD, 60'
- Setup Lab Environment, 30'
- Hands-on Techlab, Rest of the Day
- Recap and Feedback, 15'
- Learn about Jenkins best practices
- Learn how to write Pipelines
- Learn about the different kinds of implementations
- Get a basic toolset on how to implement the basic use cases
- Consists of Masters
- Stateful
- Management of Jobs, Credentials, ...
- Plugins (always run on master)
- and Slaves
- Actually run the jobs
- Stateless
- jobs = number of developers * 3.333
- masters = number of jobs/500
- executors = number of jobs * 0.03
Source: https://jenkins.io/doc/book/architecting-for-scale/
Source: http://jnatoli.deviantart.com/
- Code in scm
- Check-in and push at least daily
- Automated compiling, testing, integrating and building
- Reporting and code analysis
- Deploy to integration environment
“CONTINUOUS DELIVERY IS THE ABILITY TO GET CHANGES OF ALL TYPES—INCLUDING NEW FEATURES, CONFIGURATION CHANGES, BUG FIXES AND EXPERIMENTS—INTO PRODUCTION,OR INTO THE HANDS OF USERS, SAFELY AND QUICKLY IN A SUSTAINABLE WAY.”
-Jez Humble, continuousdelivery.com
“CONTINUOUS DELIVERY IS THE ABILITY TO GET CHANGES OF ALL TYPES—INCLUDING NEW FEATURES, CONFIGURATION CHANGES, BUG FIXES AND EXPERIMENTS—INTO PRODUCTION,OR INTO THE HANDS OF USERS, SAFELY AND QUICKLY IN A SUSTAINABLE WAY.”
-Jez Humble, continuousdelivery.com
- Developer Experience
- Self contained
- Fully automated and documented
- Reusable
- Can be reviewed, forked, iterated upon and audited
- Running pipelines survive master restart
- Can stop and wait for human input
- Support complex CI/CD requirements
- DSL can be extended through shared libraries
- Declarative: Validation => better error reporting
- Declarative: Better GUI support (Blue Ocean)
- Scripted: Rapid prototyping
- Scripted: Nearly full power of Groovy (good and bad)
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
}
node {
stage('Build') {
echo 'Building...'
}
}
- Pipelines must survive restart of the jenkins
- Scripts must serialize data back to the master
- Some Groovy idioms with closures not supported, e.g:
collection.each { item -> /* perform operation */ }
- Jobs require different build tools
- To keep slaves stateless, tools are installed dynamically during job execution
- Jenkins provides auto tool installer concept
- Seeder job that manages custom tools
- Update jobs that automatically update tools where possible
- All custom tool scripts are managed in git
- Custom tools check if they already exist (performance)
- Use folders
- Keep the slave stateless
- Archive artifacts
- Reuse functionalities in shared libraries
How to organize pipelines @ puzzle
[Customer]-[project]
hit-hitobito
pitc-appuio
Use the replay function of a pipeline
Use the replay function of a pipeline
Term | Description |
---|---|
Pipeline | A user-defined model of a continuous delivery pipeline |
Build | Result of a single execution of a Project |
Agent | An agent is typically a machine, or container, which connects to a Jenkins master and executes tasks when directed by the master. |
Node | A machine which is part of the Jenkins environment and capable of executing Pipelines or Projects. |
Job | A deprecated term, synonymous with Project. |
Stage | the phases of a pipeline are called stages |
Step | A single task; fundamentally steps tell Jenkins what to do inside of a Pipeline or Project. |
- 1 master
- 1 main slave
- OpenShift docker slaves on demand
- Currently Kubernetes plugin
- Custom slaves build with its own pipeline
- Project specific Slaves
Prior to 1.0.14 (impl. of SimpleBuildStep)
step([$class: 'OpenShiftBuilder', apiURL: .....
After 1.0.14
def builder = openshiftBuild buildConfig: 'frontend'
- 1 master deployed on OpenShift techlab env
- Every participant runs its own slave locally
- Guided, hands-on Workshop
- Docs are on GitHub
- Please help us to improve the techlab
- Jenkins Book: https://jenkins.io/doc/book/
- Examples https://jenkins.io/doc/pipeline/examples/
- OpenShift Examples: https://github.com/openshift/origin/tree/master/examples/jenkins/pipeline
- Jenkins Techlab: https://github.com/puzzle/jenkins-techlab
https://github.com/puzzle/jenkins-techlab