Back to blog

Auto-Convert Freestyle Jobs to Jenkins Pipeline

Sanil Pillai
December 15, 2017

This is a guest post by Sanil Pillai, Director of Labs & Strategic Insights, Infostretch

Infostretch has created a plugin for teams upgrading from Freestyle Jobs to Pipelines as code with Jenkins Pipeline. This new plugin streamlines the process and accelerates pipeline on-boarding for any new set of applications. Previously, when upgrading to Jenkins Pipeline, converting Freestyle Jobs required developers to drill down on each one of those hundreds (or thousands!) of jobs to understand tools, configurations, URLs, parameters, and more before rewriting them in Pipeline syntax. This process is very manual, error-prone, lengthy, and not cost-effective. Beyond saving time, the new plugin also assures adherence to proper coding standards and separates complex business logic and standards declaration from execution flow.

Key features:

  • Convert single freestyle job to pipeline

  • Convert chain of freestyle jobs to single pipeline

  • Works with both Jenkins and CloudBees Jenkins Enterprise

  • Plugin can be customized to support any Freestyle plugin and an organization’s Pipeline Shared Library, or Groovy coding standards.

  • Works with CloudBees' Role-based Access Control to help the new Pipelines comply with existing security policies.

  • Direct migration of properties such as "Build with Parameters" to newly created Pipelines.

  • Direct migration of Agent on which job is to be run with support for multiple agent labels across different downstream jobs

  • Environment properties: JDK, NodeJS

  • Supports Git SCM.

  • Build steps: Maven, Ant, Shell, Batch, and Ansible Playbook.

  • Post build actions: artifact archiver, simple mailer, TestNG reports, JUnit reports, checkstyle publisher

Now, let’s take a look at how to get started:

  1. Click on a link at Root level or Folder level or Job level.

    Image01 Jenkins Pipeline Infostretch
  2. Select the job from the drop-down list that is the beginning point of the "chain". If job level link is clicked, this drop-down list will not be visible.

    Image02 Jenkins Pipeline Infostretch

    Provide the new pipeline job name. If this is not specified, the plugin will attempt to create a new pipeline job with the naming convention of "oldname-pipeline".

  3. Check "Recursively convert downstream jobs if any?" if you wish to have all the downstream jobs converted into this new pipeline. The plugin will write all the logic of current and downstream jobs into a single pipeline.

  4. Check "Commit Jenkinsfile?" if you would like the plugin to create a Jenkinsfile and commit it back to the SCM. The plugin will commit the Jenkinsfile at the root of the SCM repository it finds in the first job (selected in step 1 above). It will attempt to commit to this repo using the credentials it finds in the first job.

  5. Do note that the plugin will checkout the repo in to a temporary workspace on the controller (JENKINS_HOME/plugins/convert-to- pipeline/ws). Once the conversion is complete and Jenkinsfile is committed back to the repo, the workspace will be deleted.

  6. Click "Convert" to convert the Freestyle job configurations to a single scripted pipeline job. Once the conversion is complete and the new job is created, you will be redirected to the newly created pipeline job.

That’s it!

To learn more about plugin usage, customization and to see a demo click here to watch the webinar replay on-demand.

About the author

Sanil Pillai

Director of Labs & Strategic Insights, Infostretch