Migrating Jenkins Environments to Jenkins 2
Achieve greater consistency, security, robustness, and maintainability
Jenkins, the industry-standard Continuous Delivery (CD) orchestrator, has evolved. In the past, using Jenkins was all about filling in web forms and knowing the right incantations to get applications to integrate correctly to create a working pipeline. Jenkins 2 is centered around using pipelines-as-code and the associated programming environment. Pipelines can now be written as structured code, with a rich, descriptive DSL, and use powerful features to automate and simplify CD job chains. Moving from the traditional Jenkins model to the pipeline-as-code model represents a huge opportunity for companies to evolve their CD pipeline to new standards of consistency, security, robustness, and maintainability.
In this course, you’ll get up and running with migrating your current Jenkins environments to Jenkins 2. You’ll also learn how to create pipelines as code with clear examples and guides. You’ll discover how to use the new interfaces and functions in Jenkins 2 to ensure you get the most out of its new features, including the new product types (including direct support for GitHub) and the Blue Ocean interface.
What you'll learn-and how you can apply it
By the end of this live, online course, you'll understand:
- The new Jenkins 2 object model and interface
- The new pipeline DSL
And you will be able to:
- Use the new features and project types in Jenkins 2
- Write a multi-stage pipeline as a Jenkins DSL script
- Develop, execute, and debug pipelines as code
This training course is for you because...
- You're a Jenkins user or support person with investments in the traditional Jenkins model and you need to understand the Jenkins 2 model
- You're a developer or tester with dependencies on Jenkins processing and you need to understand what changes you may encounter using a pipeline-as-code model and what value it can provide
To get the most out of this course, you should have:
- Experience working with the traditional Jenkins model
- Basic familiarity with the ideas and concepts of a Continuous Delivery Pipeline
- Experience using Git is helpful, but not required
For this course, you'll use a preconfigured VM image. Prior to taking the course, you should:
Install Virtualbox on your system and ensure it can be started cleanly
Download the VM image from:
Complete the remaining setup instructions at:
About your instructor
Brent Laster is a global trainer, author, and speaker on open source technologies as well as a senior R&D manager at a top technology company. He has been involved in the software industry for more than 25 years, holding various technical and management positions.
Brent has always tried to make time to learn and develop both technical and leadership skills and share them with others. He believes that regardless of the topic or technology, there’s no substitute for the excitement and sense of potential that come from providing others with the knowledge they need to accomplish their goals.
The timeframes are only estimates and may vary according to how the class is progressing
Section 1: Introduction to Jenkins 2 (25 minutes - instructor lecture + Q&A)
- Reasons for the evolution
- Installation differences
- New project types
- Advantages of pipeline-as-code
- About the DSL
- Using the script editor
- Understanding the stage view
Lab 1: Creating a simple pipeline script (15 min - 10 min activity + 5 min break)
- Start up the VM image and use Jenkins 2 to create a simple first pipeline.
Section 2: Pipeline Tooling basics (20 minutes - instructor lecture + Q&A)
- DSL Syntax
- Using username/password credentials in your script
- Using SSH credentials in your script
- Defining and accessing Global Tools
- Introducing the Replay functionality
Lab 2: Adding a build stage (15 min - 10 min activity + 5 min break)
- Add a new build stage onto the pipeline from lab 1. Observe what encountering an error in a pipeline script looks like and use the Replay functionality to construct a fix and verify that it works.
Section 3: Managing security with pipeline scripts and using shared libraries (20 minutes - instructor lecture + Q&A)
Controlling Script Security
Shared Pipeline Libraries
Defining Global Shared Libraries
- Using Libraries and Resources
Lab 3: Using Shared Libraries (15 min - 10 min activity + 5 min break)
- Add a global reference to a shared library in Jenkins and modify your pipeline script to incorporate the reference in place of the previous functionality.
Section 4: Incorporating external code directly and managing flow control
- Plugin compatibility for pipeline scripts
- Loading external code to use
- Using the snippet generator
- Flow control in the pipeline
- User Inputs
- Controlling concurrency with milestones
Lab 4: Loading Groovy code directly, user inputs, timeouts, and the Snippet Generator (15 min - 10 min activity + 5 min break) (20 minutes - instructor lecture + Q&A)
- Modify your scripts to include external code and leverage the Snippet Generator to create code for flow control in the script. Interact with a script waiting for user input.
Section 5: Global functions; exception handling in pipelines (15 minutes - instructor lecture + Q&A)
- Continuous Passing Style and what it means for pipelines
- Defining global functions
- Exception handling in pipelines
Lab 5: Using global functions and exception handling (15 min - 10 min activity + 5 min break)
- Add a stage to your pipeline that uses a global function. Work with user input in pipeline DSL and adding exception handling.
Section 6: Jenkinsfiles and new project types (15 minutes - instructor lecture + Q&A)
- Folder projects
- The Jenkinsfile
- Multibranch projects
- Github Organization projects
Lab 6: Multibranch projects (15 min - 10 min activity + 5 min break)
- Set up a multibranch project with a Jenkinsfile and see how Jenkins automatically detects new branches and creates associated projects.
Section 7: Jenkins 2 and parallelism (20 minutes - instructor lecture + Q&A)
Lab 7: Running in parallel and across multiple nodes (15 min - 10 min
activity + 5 min break)
- Add code to your pipeline to do parallel processing across multiple nodes.
Section 8: Declarative pipelines (20 minutes - instructor lecture + Q&A)
- Plugins needed for declarative pipelines
- Motivation for declarative pipelines
- Basics of declarative pipelines
- New sections
- Postbuild notifications
- Build conditions
- Declarative pipeline example
- Enhanced validation with syntax and error checking
Lab 8: Creating a Declarative Pipeline (15 min - 10 min activity + 5 min
- Convert your existing pipeline script to fit the declarative model
Section 9: Blue Ocean user interface (10 minutes - instructor lecture + Q&A)
- General form
- Examples of runs in-progress, succeeded, and failed
- Viewing logs
Lab 9: Using Blue Ocean (15 min - 10 min activity + 5 min break)
- Execute and observe a run of your declarative pipeline through the Blue Ocean interface.
Section 10: Jenkins 2.0 and Docker (20 minutes - instructor lecture + Q&A)
- Running Docker configured as a cloud
- Using the built-in DSL step to run commands in a container
- DSL step additional operations
- Running Docker directly via a shell call
Lab 10: Integrating Docker (15 min - 10 min activity + 5 min break)
- Modify your pipeline to build a new image from a Dockerfile. Invoke Docker images in your pipeline..
Wrap-up and remaining Q&A (15 min)