2.0 Break the cocoon

Since the end of September of last year Jenkins founder
Kohsuke KawaguchiJenkins 2.0 (hereafter referred to as 2.0)
visionand
The draftSince then, the entire Jenkins community has been elated, with both the official blog and the Google forums abuzz with discussions and anticipation of 2.0. On April 20th, after three iterations of Alpha (2/29), Beta (3/24), and RC (4/7), 2.0 was officially released. This is the first major Jenkins update in its 11-year history (including its predecessor Hudson). So what exactly does this upgrade involve?


external

Externally, the three biggest selling points of 2.0 are Pipeline as Code, a new out-of-the-box experience, and 1.x compatibility.






Pipeline as CodeIs the essence of 2.0, is to help Jenkins to achieve CI (Continuous Integration) to CD (Continuous Delivery) the key driver. The so-called Pipeline, simply speaking, is a workflow framework running on Jenkins, which connects tasks that originally run independently on a single or multiple nodes to achieve a complex release process that is difficult to be completed by a single task (for example, the figure below). Pipeline is implemented as a Groovy DSL (similar to Gradle). Any publishing process can be expressed as a Groovy script, and Jenkins supports reading scripts directly from the Code base, thus implementing the concept of Pipeline as Code.




New unpacking experienceIn an attempt to reverse what we remember as Jenkins’ lackluster interface for a decade, not only the Jenkins app itself, but also the website layout, blog style and even the domain name have been redesigned. In addition to greatly improving user experience, these changes are more important to convey a clear signal to people that Jenkins is no longer just a CI tool, but contains infinite possibilities.





1. X compatibilityTo all old version users eat a big reassurance, note, is fully compatible oh.


internal

Internally, 2.0 includes some component upgrades and JS modularization.


  • Upgrade Servlet version to 3.1 to get Web Sockets support.

  • Update the embedded Groovy version to 2.4.6.

    • The Groovy update is just the first step in a future Jenkins release that will completely strip Groovy from the kernel.
  • Provides a simplified JS class library for Plugin developers to use.





Better containerization support

With containerization technology (represented by Docker) heating up, Jenkins jumped on the bandwagon, not only synchronously uploading 2.0 Docker images, but also providing the default in Pipeline
Docker support.





In addition to the above, there is another interesting change in 2.0. The global renaming of Slave to Agent is also very important for IT political correctness in the US.


Pipeline as Code

With the overview of 2.0 behind us, let’s take a look at the background and structure of Pipeline as Code.


background

As a core 2.0 plug-in, Pipeline is not new, its predecessor is
Workflow PluginWorkflow comes much earlier than that
Build Flow PluginInspired by the
Nicolas De LoofThe first version was released in April 2012. And a look at several of Jenkins’ competitors (
Travis CI,
PHPCI,
CircleCIPipeline is not a new concept. It’s fair to say that the Jenkins 2.0 release is in line with the trend.





If we want to explore the background of Pipelined on a larger scale, I think there are three reasons:


  • The first level is related to the increasing complexity of publishing, and a typical scenario is greyscale publishing. Grayscale publishing was originally only available to large companies. With the widespread adoption of agile development practices, the continuous shortening of product iteration cycle, and the popularity of the concept of data growth, more and more small and medium-sized companies have begun to explore this aspect, which has upgraded the demand for publishing from point-like CI to line-like CD. This is the first reason pipelines come into being.
  • The second level is related to the modular evolution of application architecture, represented by microservices. An application upgrade often involves the coordinated release of multiple modules, and a single CI is obviously unable to meet such requirements. This is the second reason for pipelines.
  • The third level has to do with the increasingly out of control number of CI. On the one hand, package management tools such as Maven, PIP, and RubyGems have led to an explosion in applications requiring CI. On the other hand, thanks to the convenient Git branching feature, multiple cis are often required to be configured even for the same application. As the number of cis continues to grow, centralized task configuration becomes a bottleneck, requiring responsibility for task configuration to be delegated to the application team. This is the third reason for pipelines (as Code).





Specific composition

Finish the background, and then look at the specific composition and characteristics of Pipeline.





Basic Concepts:


  • Stages: A Pipeline can be divided into stages, each representing a set of operations. Note that Stage is a logical grouping concept that can span multiple nodes.
  • Node: A Node is a Jenkins Node, either Master or Agent, which is the specific runtime environment for executing Step.
  • Step: Step is the most basic operation unit, ranging from creating a directory to building a Docker image, which is provided by various Jenkins plugins.





Specific composition:






2.0 supports three types of pipelines by default: normal pipelines, Multibranch pipelines and Organization Folders. The latter two are actually shortcuts to batch create a group of normal pipelines. They correspond to multi-branch applications and multi-application large organizations. Note that an additional Plugin is required to obtain support for Organization Folders.





It is worth mentioning that 2.0 has two important features:






Sample Pipeline

The example Pipeline mentioned above can be found in my
GitHubFind, if you have a question to discuss with me, you can add my QQ: 7789059.


reference

  • The Need for Jenkins Pipeline
  • Jenkins 2.0
  • Why Pipeline?
  • Pipeline-as-code with Multibranch Workflows in Jenkins