Chapter 10. Conversions

With the advent of Jenkins 2, the Jenkins user now has many options for ways to create and express pipelines. They include the traditional Freestyle jobs, pipeline code in the Jenkins application itself, and pipeline code stored in Jenkinsfiles. Additionally, pipeline code can be written either in the Scripted Pipeline syntax or the Declarative Pipeline syntax. With all of these ways to define pipelines, it is highly likely that the user will need, or want, to do some sort of conversion between the various forms at some point. This chapter will provide guidelines on accomplishing some of these conversions.

In particular, we’ll focus on three main types of conversions:

  • Converting from Freestyle jobs to a pipeline in the Jenkins application

  • Converting from a Scripted Pipeline to a Jenkinsfile

  • Converting from a Scripted Pipeline to a Declarative Pipeline

“Freestyle”

Note that we are using the term “Freestyle” here loosely, to mean any traditional Jenkins job or pipeline created via the web forms. This most typically will be using the Freestyle job type, although other types might be used as well. For other job types, the general concepts and discussions should still apply.

Rather than attempt to provide every detail about how to do a conversion, we’ll focus on guidelines and some selected examples to illustrate the approach and principles involved for each of these categories. While these do not cover every possible case, they should cover enough ...

Get Jenkins 2: Up and Running now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.