Skip to end of metadata
Go to start of metadata

Plugin Information

View Convert To Pipeline on the plugin site for more information.

About the plugin

This plugin converts Freestyle jobs to scripted Pipeline job.

Target problem

  • An organisation may have several applications which in turn will have several Freestyle jobs in Jenkins. The jobs may be "chained" together to perform builds in series based on certain conditions. This makes management of several jobs difficult over time. The concept of configuration as a code comes in to solve this and pipeline jobs are the recommended way.
  • In order to convert several Freestyle jobs to pipeline, the DevOps engineers will have to manually drill down to each of the 100s or 1000s of Freestyle jobs, understand the tools, configurations, URLs, parameters etc. and re-write them in pipeline syntax. The task will not only involve converting individual job logic but also ensuring the "chain" is converted to a single pipeline. Keeping a base-rule of 1 chain = 1 pipeline.
  • This plugin helps to solve this as it drastically reduces the effort of the engineer to only perform a refinement of business logic of the auto-generated pipeline script rather than the manual task of conversion.
  • The plugin can be further customised to enforce each organisation's standards as well as industry standards which all applications will have to follow. This makes it easier to enforce at Jenkins level.
  • The auto-generated scripts can be pre-configured to use custom libraries which make it easy to separate complex business logics and standard declaration from execution flow declaration. This will also make maintenance tasks easier in the future.
  • The plugin will also make the transition process of any new set of applications being on-boarded to pipeline much faster and systematic.

 

Interface

The plugin provides a link on the left menu at 3 locations:

Root LevelFolder LevelFreestyle Job level

 

Click on the link at any given level and a UI similar to below will appear:

Usage

  1. Click on a link at Root level or Folder level or Job level.
  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.
  3. 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".
  4. 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.
  5. 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.
    1. Do note that the plugin will checkout the repo in to a temporary workspace on the master (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 in 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.

Contact / Support

Please contact Infostretch through labs_support@infostretch.com for any issues or support required.

12 Comments

  1. Hi Mohit,

    I am glad to see this plug-in. May I know which version of Jenkins has this plug-in. We have so many free-style and multi-jobs which we would like to convert to groovy pipeline.

    I would greatly appreciate if you could guide me on how to install and configure it?

     

    Thank you so much for your attention.

     

    Regards,

    Mahesh

     

    1. Hi Mahesh,

      Thank you for your interest in the plugin. The plugin is now open-source and can be downloaded via the update center.

      In case you are not able to see it there yet; you can download it from the Archives section on "https://plugins.jenkins.io/convert-to-pipeline"

      Regards,

      Mohit

  2. Hi Mohit,

    Thanks for your effort on the plugin. It is handy to convert a huge set of jobs into Jenkins Pipeline code. Could you enable the Use Groovy Sandbox checkbox on the created job, by default, so that Administrators do not have to approve each and every converted job?

    Thanks,

    George Davis C.

    1. Hi George,

      The idea behind not enabling "Groovy Sandbox" is to go with the concept of configuration as code.

      Once the script has been converted but kept inline, then it is subject to testing and verification.

      When tested and verified, the script should be committed back to SCM with the marker file being Jenkinsfile.

      The plugin already provides an option to push the groovy code with the corresponding Jenkinsfile back to the SCM. Use this option if you safely assume that the conversion and the contents of the script are as desired. The newly created pipeline job will then be configured to use "Pipeline script from SCM" which eliminates the need for Sandbox checkbox.

      Thanks,

      Mohit

  3. Hi Mohit or anyone,

        I installed the plugin but i don't see the "convert  to pipeline" link on any of the menu. I've update all required/depend plugins to higher version than recommended. any ideas on what I could have done incorrectly?

     

    1. Hi Danny,

      Could you raise a Jenkins-JIRA issue about this providing further details about the type of job you are converting, Jenkins version, OS.

      In the ticket, you could also provide a sample config.xml (remove any sensitive info) of the source job. Refer to this issue and ensure it is not the same that you are facing. JENKINS-48659 - Getting issue details... STATUS

      Thanks,

      Mohit

      1. Hi Mohit,

            I'm trying to convert a free style job. The issue I'm having is that the link is missing for me to start the conversion process. The link in red is missing. 

         

        1. Im not sure why the picture is broken. Here is the screenshot again. It doesn't have the "convert to pipeline" link.

  4. To all users of the plugin,

    Thank you for installing it.

    If you run into any issue, find a bug, in-correct or different behavior from what has been described, have a new feature request, need more clarification or any other matter, please use one of below paths in order to get support or better response:

    1. Raise a Jenkins-JIRA ticket with as much details as possible. 
      1. Provide a complete set of screenshots. The more 'general' a screenshot you provide; the less likely we are close to a solution.
      2. Provide a sample config.xml file if possible of the job you are trying to convert. Remove any sensitive information from it.
      3. Check Jenkins logs to ensure the plugin was loaded and no error occurred at start-up.
    2. Create a pull-request with a proposed solution.
    3. Send an email to labs_support@infostretch.com.
  5. I have a master in Linux and Created a Slave in Windows. Now when i try to convert a freestyle job to Pipeline using the "Convert This Job To Pipeline" nothing seem to happen. Pipeline Job is created but "Commit Jenkinsfile" for some reason is not working. Meaning i don't see the file checked into SCM. Is there a way i can check if the Jenkinsfile is created on Windows?

  6. When I Commit Jenkinsfile,  I find my repo's branch code dispeared, just created a jenkinsfiles. 

    It is very danger action. Can fix it? 

    I feel the good choise is that it create a jenkinsfiles and not delete my origin code.

    1. Here samething happend on two repos. Master-branch is empty, only the new jenkinsfile is their. No History left. But our Developers were able to merge-unrelated-histories.