SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Jenkins as a Service
Code all the way down
Steve Mactaggart
Application Delivery Evangineer
The moving parts
Infrastructure (AWS / ECS)
Application (Jenkins)
Configuration (Jenkins Jobs)
The moving parts - AS CODE
Infrastructure (AWS / ECS)
Application (Jenkins)
Configuration (Jenkins Jobs)
CloudFormation
Docker containers
Groovy / Jenkins DSL
Everything as code
• Consistently repeatable process
• Enables a strong self service workflow
• Highly visible traceability of change
• Roll forward / rollback
The moving parts - Infrastructure
Infrastructure (AWS / ECS)
Application (Jenkins)
Configuration (Jenkins Jobs)
CloudFormation
Docker containers
Groovy / Jenkins DSL
Infrastructure
• Infrastructure captured as Code
• Designed for easy re-use per team
• Deployable into existing VPCs
• Common location to share learned lessons
Infrastructure / AWS
EC2
Infrastructure - Simplified
ap-southeast-2bap-southeast-2a
ECS agent auto-scaling group
ECS master auto-scaling group
EC2 EC2
Infrastructure / AWS /
CloudFormation
ECS configuration
Master ECR
Agent ECR
AWS ECS
CloudWatch logs
EC2
Infrastructure
ap-southeast-2bap-southeast-2a
ECS agent auto-scaling group
ECS master auto-scaling groupECS configuration
Master ECR
Agent ECR
Legend
ECS ScaleDown
function
ECS Memory
Reservation Alarm
Termination Event
AWS ECS
EC2 EC2
Query for tasks running on host
Continue the ASG lifecycle hook
Publish intent to
terminate
Watch for ScaleUp
/ ScaleDown alarm
Consume
message
Containers download configuration
ECSLaunches
AgentTask
Launch / Terminate
EC2 Instance
Jenkins Schedules
new Task via ECS
JenkinsAgent
phoneshometo
Mastercontainer
Direct TCP call
S3 download
AWS API Call
Retrieve Master container from ECR
Retrieve Agent container from ECR
EC2instance
registerswith
ECS
Agentcontainer
registerswithmaster
ALB routes web traffic
Infrastructure / AWS /
CloudFormation
CloudWatch logs
EC2 / ECS logs shipped
to CloudWatch
Infrastructure
• Example CloudFormation
• https://bitbucket.org/stevemac/dock
erfiles/src/282408c04239/cloudforma
tion/?at=master
• 2 stacks
• Infrastructure (2x ECS clusters)
• Cluster - Jenkins Master Service
The moving parts - Application
Infrastructure (AWS / ECS)
Application (Jenkins)
Configuration (Jenkins Jobs)
CloudFormation / Terraform
Docker containers
Groovy / Jenkins DSL
EC2
Jenkins in Docker
ap-southeast-2bap-southeast-2a
ECS agent auto-scaling group
ECS master auto-scaling group
EC2 EC2
ECS configuration
Master ECR
Agent ECR
AWS ECS
CloudWatch logs
Jenkins Application /
Docker containers
Jenkins
Master
Jenkins
Agents
The Jenkins Master and its Agents
• Jenkins is an Application
• We understand the Docker application workflow
• Immutable Applications increase confidence of changes
• Based of official JenkinsCI base containers
• From jenkinsci/Jenkins
• From jenkinsci/slave
• Extended to include specific build and deployment tools
• Python / AWSCli / etc
Jenkins Application /
Docker containers
Jenkins master - Dockerfile
Jenkins Application /
Docker containers
Jenkins agent - Dockerfile
Jenkins Application /
Docker containers
Jenkins in Docker
• Many plugins in-use:
• build-pipeline-plugin
• amazon-ecs
• delivery-pipeline-plugin
• build-monitor-plugin
• gitlab-merge-request-Jenkins
• Etc…
• State persisted through Docker volume mount
• Example Master and Agent Docker containers
• https://bitbucket.org/stevemac/dockerfiles/src/
The moving parts - Configuration
Infrastructure (AWS / ECS)
Application (Jenkins)
Configuration (Jenkins Jobs)
CloudFormation / Terraform
Docker containers
Groovy / Jenkins DSL
Configuration as Code - setup
• Start of the configuration delivered in Dockerfiles
• Configuration and ssh keys downloaded from S3 bucket
• Supplied to container as Environment variable
Configuration / Groovy
Configuration as Code - setup
• Runtime configuration automated through use of custom Groovy
initialisation scripts within the container
• Groovy is used to configure:
• Jenkins credentials
• ECS Cluster configuration
• Jenkins Bootstrap job
• Executed as part of Dockerfile entrypoint
Configuration / Groovy
Pipeline as Code - runtime
• Using the Jenkins DSL pipeline
• https://bitbucket.org/jenkinspipeline/jenkins-dsl-examples
• Using the power of Groovy code to create reusable elements
• Version controlled through Git
• Repeatable / reliable / extensible
• See https://github.com/jenkinsci/job-dsl-plugin/wiki/Tutorial---Using-the-Jenkins-Job-DSL
• Automatic documentation available within each Jenkins instance
Configuration / Jenkins DSL
Lets talk about
a Jenkinsfile
approach over a
beer
Pipeline as Code – groovy constructs
Configuration / Groovy /
Jenkins DSL
Pipeline as Code - example
https://bitbucket.org/jenkinspipeline/jenkins-dsl-examples
1. build_pipeline.groovy
Creation of example build jobs - CI
2. delivery_pipeline.groovy
Creation of example jobs for a candidate delivery pipeline - CD
3. views.groovy
Creation of some standard pipeline views
Configuration / Groovy /
Jenkins DSL
Bringing it together
Let our codebases combine
Executed within
ECS Jenkins service
Result of
infrastructure deploy
Performed by operator
Delivery workflow
Build and
Publish Docker
Containers
Launch Stack
Publish keys to
S3 bucket
Create ECS
Service
Retrieve latest
Docker image
from ECR
Launch ECS
Task
Download keys
from S3
Clone groovy
config repo
Launch Jenkins
Master Process
Groovy config
executed
Bootstrap job
generates
pipelines
Followup discussions
1. Migrating to a Jenkins-as-code approach
2. Jenkins DSL vs Jenkinsfiles
3. All about Jenkins State
4. Security in a stateless world
5. Advanced Jenkins DSL patterns
Thanks !
Steve Mactaggart
• Application Delivery Evangineer at Cevo
• @stevemac
Example working code available at:
https://bitbucket.org/stevemac/dockerfiles

Weitere ähnliche Inhalte

Was ist angesagt?

Build & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWSBuild & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWS
Docker, Inc.
 

Was ist angesagt? (20)

DevOps with Azure, Kubernetes, and Helm Webinar
DevOps with Azure, Kubernetes, and Helm WebinarDevOps with Azure, Kubernetes, and Helm Webinar
DevOps with Azure, Kubernetes, and Helm Webinar
 
Dell Trials and Triumphs using Docker on Client Systems by Sean McGinnis and ...
Dell Trials and Triumphs using Docker on Client Systems by Sean McGinnis and ...Dell Trials and Triumphs using Docker on Client Systems by Sean McGinnis and ...
Dell Trials and Triumphs using Docker on Client Systems by Sean McGinnis and ...
 
TestCorner#22 - Evolving QA implementation for Microservices in Viveport
TestCorner#22 - Evolving QA implementation for Microservices in ViveportTestCorner#22 - Evolving QA implementation for Microservices in Viveport
TestCorner#22 - Evolving QA implementation for Microservices in Viveport
 
Build & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWSBuild & Deploy Multi-Container Applications to AWS
Build & Deploy Multi-Container Applications to AWS
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Lessons Learned Building a Container App Library
Lessons Learned Building a Container App LibraryLessons Learned Building a Container App Library
Lessons Learned Building a Container App Library
 
Docker for developers on mac and windows
Docker for developers on mac and windowsDocker for developers on mac and windows
Docker for developers on mac and windows
 
CI/CD with Docker on AWS
CI/CD with Docker on AWSCI/CD with Docker on AWS
CI/CD with Docker on AWS
 
Development environments in seconds using Bitnami containers
Development environments in seconds using Bitnami containersDevelopment environments in seconds using Bitnami containers
Development environments in seconds using Bitnami containers
 
Efficient Parallel Testing with Docker by Laura Frank
Efficient Parallel Testing with Docker by Laura FrankEfficient Parallel Testing with Docker by Laura Frank
Efficient Parallel Testing with Docker by Laura Frank
 
Kubernetes CI/CD with Helm
Kubernetes CI/CD with HelmKubernetes CI/CD with Helm
Kubernetes CI/CD with Helm
 
DockerCon SF 2015: Docker at Lyft
DockerCon SF 2015: Docker at LyftDockerCon SF 2015: Docker at Lyft
DockerCon SF 2015: Docker at Lyft
 
DCEU 18: 5 Patterns for Success in Application Transformation
DCEU 18: 5 Patterns for Success in Application TransformationDCEU 18: 5 Patterns for Success in Application Transformation
DCEU 18: 5 Patterns for Success in Application Transformation
 
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment ModelUsing Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
Using Docker Hub at Scale to Support Micro Focus' Delivery and Deployment Model
 
CI/CD Pipeline mit Gitlab CI und Kubernetes
CI/CD Pipeline mit Gitlab CI und KubernetesCI/CD Pipeline mit Gitlab CI und Kubernetes
CI/CD Pipeline mit Gitlab CI und Kubernetes
 
Node.js Rocks in Docker for Dev and Ops
Node.js Rocks in Docker for Dev and OpsNode.js Rocks in Docker for Dev and Ops
Node.js Rocks in Docker for Dev and Ops
 
CI/CD with Openshift and Jenkins
CI/CD with Openshift and JenkinsCI/CD with Openshift and Jenkins
CI/CD with Openshift and Jenkins
 
Lean Cloud Starterkit - Beta
Lean Cloud Starterkit - BetaLean Cloud Starterkit - Beta
Lean Cloud Starterkit - Beta
 
Java in a world of containers
Java in a world of containersJava in a world of containers
Java in a world of containers
 
Intro to docker - innovation demo 2022
Intro to docker - innovation demo 2022Intro to docker - innovation demo 2022
Intro to docker - innovation demo 2022
 

Ähnlich wie Jenkins as a Service - Code all the way down

Ähnlich wie Jenkins as a Service - Code all the way down (20)

(DVO305) Turbocharge YContinuous Deployment Pipeline with Containers
(DVO305) Turbocharge YContinuous Deployment Pipeline with Containers(DVO305) Turbocharge YContinuous Deployment Pipeline with Containers
(DVO305) Turbocharge YContinuous Deployment Pipeline with Containers
 
Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2Pipeline as code - new feature in Jenkins 2
Pipeline as code - new feature in Jenkins 2
 
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
04_Azure Kubernetes Service: Basic Practices for Developers_GAB201904_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
 
Pipelining DevOps with Jenkins and AWS
Pipelining DevOps with Jenkins and AWSPipelining DevOps with Jenkins and AWS
Pipelining DevOps with Jenkins and AWS
 
Continuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container ServiceContinuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container Service
 
DevOps World | Jenkins World 2018 and The Future of Jenkins
DevOps World | Jenkins World 2018 and The Future of JenkinsDevOps World | Jenkins World 2018 and The Future of Jenkins
DevOps World | Jenkins World 2018 and The Future of Jenkins
 
Continuous Delivery to Amazon ECS - AWS August Webinar Series
Continuous Delivery to Amazon ECS - AWS August Webinar SeriesContinuous Delivery to Amazon ECS - AWS August Webinar Series
Continuous Delivery to Amazon ECS - AWS August Webinar Series
 
Cicd pixelfederation
Cicd pixelfederationCicd pixelfederation
Cicd pixelfederation
 
Docker and kubernetes
Docker and kubernetesDocker and kubernetes
Docker and kubernetes
 
JUC Europe 2015: From Virtual Machines to Containers: Achieving Continuous In...
JUC Europe 2015: From Virtual Machines to Containers: Achieving Continuous In...JUC Europe 2015: From Virtual Machines to Containers: Achieving Continuous In...
JUC Europe 2015: From Virtual Machines to Containers: Achieving Continuous In...
 
From Virtual Machines to Containers
From Virtual Machines to ContainersFrom Virtual Machines to Containers
From Virtual Machines to Containers
 
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
Jenkins vs. AWS CodePipeline (AWS User Group Berlin)
 
dockerSAW
dockerSAWdockerSAW
dockerSAW
 
Continuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container ServiceContinuous Delivery to Amazon EC2 Container Service
Continuous Delivery to Amazon EC2 Container Service
 
2016 Docker Palo Alto - CD with ECS and Jenkins
2016 Docker Palo Alto -  CD with ECS and Jenkins2016 Docker Palo Alto -  CD with ECS and Jenkins
2016 Docker Palo Alto - CD with ECS and Jenkins
 
Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14Docker dev ops for cd meetup 12-14
Docker dev ops for cd meetup 12-14
 
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @OrbitzEnabling Hybrid Workflows with Docker/Mesos @Orbitz
Enabling Hybrid Workflows with Docker/Mesos @Orbitz
 
Microservices with containers in the cloud
Microservices with containers in the cloudMicroservices with containers in the cloud
Microservices with containers in the cloud
 
Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
 
Priming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the CloudPriming Your Teams For Microservice Deployment to the Cloud
Priming Your Teams For Microservice Deployment to the Cloud
 

Mehr von Steve Mactaggart

Mehr von Steve Mactaggart (6)

5 DevOps things that have changed because of COVID-19
5 DevOps things that have changed because of COVID-195 DevOps things that have changed because of COVID-19
5 DevOps things that have changed because of COVID-19
 
Introduction to CI/CD
Introduction to CI/CDIntroduction to CI/CD
Introduction to CI/CD
 
Are you a leadership group or a leadership team?
Are you a leadership group or a leadership team?Are you a leadership group or a leadership team?
Are you a leadership group or a leadership team?
 
Test driven infrastructure
Test driven infrastructureTest driven infrastructure
Test driven infrastructure
 
The changing role of the team leader in a DevOps transformation
The changing role of the team leader in a DevOps transformationThe changing role of the team leader in a DevOps transformation
The changing role of the team leader in a DevOps transformation
 
Head in the clouds
Head in the cloudsHead in the clouds
Head in the clouds
 

Kürzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 

Jenkins as a Service - Code all the way down

  • 1. Jenkins as a Service Code all the way down Steve Mactaggart Application Delivery Evangineer
  • 2. The moving parts Infrastructure (AWS / ECS) Application (Jenkins) Configuration (Jenkins Jobs)
  • 3. The moving parts - AS CODE Infrastructure (AWS / ECS) Application (Jenkins) Configuration (Jenkins Jobs) CloudFormation Docker containers Groovy / Jenkins DSL
  • 4. Everything as code • Consistently repeatable process • Enables a strong self service workflow • Highly visible traceability of change • Roll forward / rollback
  • 5. The moving parts - Infrastructure Infrastructure (AWS / ECS) Application (Jenkins) Configuration (Jenkins Jobs) CloudFormation Docker containers Groovy / Jenkins DSL
  • 6. Infrastructure • Infrastructure captured as Code • Designed for easy re-use per team • Deployable into existing VPCs • Common location to share learned lessons Infrastructure / AWS
  • 7. EC2 Infrastructure - Simplified ap-southeast-2bap-southeast-2a ECS agent auto-scaling group ECS master auto-scaling group EC2 EC2 Infrastructure / AWS / CloudFormation ECS configuration Master ECR Agent ECR AWS ECS CloudWatch logs
  • 8. EC2 Infrastructure ap-southeast-2bap-southeast-2a ECS agent auto-scaling group ECS master auto-scaling groupECS configuration Master ECR Agent ECR Legend ECS ScaleDown function ECS Memory Reservation Alarm Termination Event AWS ECS EC2 EC2 Query for tasks running on host Continue the ASG lifecycle hook Publish intent to terminate Watch for ScaleUp / ScaleDown alarm Consume message Containers download configuration ECSLaunches AgentTask Launch / Terminate EC2 Instance Jenkins Schedules new Task via ECS JenkinsAgent phoneshometo Mastercontainer Direct TCP call S3 download AWS API Call Retrieve Master container from ECR Retrieve Agent container from ECR EC2instance registerswith ECS Agentcontainer registerswithmaster ALB routes web traffic Infrastructure / AWS / CloudFormation CloudWatch logs EC2 / ECS logs shipped to CloudWatch
  • 9. Infrastructure • Example CloudFormation • https://bitbucket.org/stevemac/dock erfiles/src/282408c04239/cloudforma tion/?at=master • 2 stacks • Infrastructure (2x ECS clusters) • Cluster - Jenkins Master Service
  • 10. The moving parts - Application Infrastructure (AWS / ECS) Application (Jenkins) Configuration (Jenkins Jobs) CloudFormation / Terraform Docker containers Groovy / Jenkins DSL
  • 11. EC2 Jenkins in Docker ap-southeast-2bap-southeast-2a ECS agent auto-scaling group ECS master auto-scaling group EC2 EC2 ECS configuration Master ECR Agent ECR AWS ECS CloudWatch logs Jenkins Application / Docker containers Jenkins Master Jenkins Agents
  • 12. The Jenkins Master and its Agents • Jenkins is an Application • We understand the Docker application workflow • Immutable Applications increase confidence of changes • Based of official JenkinsCI base containers • From jenkinsci/Jenkins • From jenkinsci/slave • Extended to include specific build and deployment tools • Python / AWSCli / etc Jenkins Application / Docker containers
  • 13. Jenkins master - Dockerfile Jenkins Application / Docker containers
  • 14. Jenkins agent - Dockerfile Jenkins Application / Docker containers
  • 15. Jenkins in Docker • Many plugins in-use: • build-pipeline-plugin • amazon-ecs • delivery-pipeline-plugin • build-monitor-plugin • gitlab-merge-request-Jenkins • Etc… • State persisted through Docker volume mount • Example Master and Agent Docker containers • https://bitbucket.org/stevemac/dockerfiles/src/
  • 16. The moving parts - Configuration Infrastructure (AWS / ECS) Application (Jenkins) Configuration (Jenkins Jobs) CloudFormation / Terraform Docker containers Groovy / Jenkins DSL
  • 17. Configuration as Code - setup • Start of the configuration delivered in Dockerfiles • Configuration and ssh keys downloaded from S3 bucket • Supplied to container as Environment variable Configuration / Groovy
  • 18. Configuration as Code - setup • Runtime configuration automated through use of custom Groovy initialisation scripts within the container • Groovy is used to configure: • Jenkins credentials • ECS Cluster configuration • Jenkins Bootstrap job • Executed as part of Dockerfile entrypoint Configuration / Groovy
  • 19. Pipeline as Code - runtime • Using the Jenkins DSL pipeline • https://bitbucket.org/jenkinspipeline/jenkins-dsl-examples • Using the power of Groovy code to create reusable elements • Version controlled through Git • Repeatable / reliable / extensible • See https://github.com/jenkinsci/job-dsl-plugin/wiki/Tutorial---Using-the-Jenkins-Job-DSL • Automatic documentation available within each Jenkins instance Configuration / Jenkins DSL Lets talk about a Jenkinsfile approach over a beer
  • 20. Pipeline as Code – groovy constructs Configuration / Groovy / Jenkins DSL
  • 21. Pipeline as Code - example https://bitbucket.org/jenkinspipeline/jenkins-dsl-examples 1. build_pipeline.groovy Creation of example build jobs - CI 2. delivery_pipeline.groovy Creation of example jobs for a candidate delivery pipeline - CD 3. views.groovy Creation of some standard pipeline views Configuration / Groovy / Jenkins DSL
  • 22. Bringing it together Let our codebases combine
  • 23. Executed within ECS Jenkins service Result of infrastructure deploy Performed by operator Delivery workflow Build and Publish Docker Containers Launch Stack Publish keys to S3 bucket Create ECS Service Retrieve latest Docker image from ECR Launch ECS Task Download keys from S3 Clone groovy config repo Launch Jenkins Master Process Groovy config executed Bootstrap job generates pipelines
  • 24. Followup discussions 1. Migrating to a Jenkins-as-code approach 2. Jenkins DSL vs Jenkinsfiles 3. All about Jenkins State 4. Security in a stateless world 5. Advanced Jenkins DSL patterns
  • 25. Thanks ! Steve Mactaggart • Application Delivery Evangineer at Cevo • @stevemac Example working code available at: https://bitbucket.org/stevemac/dockerfiles