Skip to content

Latest commit

 

History

History

jenkins-job-wrecker

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Jenkins Job Wrecker - Translate Jenkins XML jobs to Jenkins Job Builder YAML

Have a lot of Jenkins jobs that were crafted by hand over the years? This tool could help you to convert your Jenkins jobs to JJB YAML.

Installation

Follow https://github.com/ktdreyer/jenkins-job-wrecker

Experiment

Get job config files

for JOB in `curl http://$JENKINS_ADDRESS/view/EAP7/view/PrettyPrint/api/json?pretty=true 2> /dev/null| grep name | grep pretty-print | cut -d: -f2 | cut -d\" -f2`; do 
  echo "$JOB"
  curl -s -k --negotiate -u aaa:a https://$JENKINS_ADDRESS/job/$JOB/config.xml > $JOB.xml
done

Transform job config files to YAML

jjwrecker -f pretty-print-smoke-rhel.xml -n pretty-print-smoke-rhel -o jjb
cat jjb/pretty-print-smoke-rhel.yml

for i in `ls pretty-print-*`; do echo $i; jjwrecker -f $i -n `echo $i | sed "s/.xml//g"` -o jjb; done

Result: 3x fail, related to this xml snipet which can't be processed / transformed:

    <org.jenkinsci.plugins.proccleaner.PreBuildCleanup plugin="[email protected]">
      <cleaner class="org.jenkinsci.plugins.proccleaner.PsCleaner">
        <killerType>org.jenkinsci.plugins.proccleaner.PsAllKiller</killerType>
        <killer class="org.jenkinsci.plugins.proccleaner.PsAllKiller" reference="../../../../publishers/org.jenkinsci.plugins.proccleaner.PostBuildCleanup/cleaner/killer"/>
        <switchedOff>false</switchedOff>
      </cleaner>
    </org.jenkinsci.plugins.proccleaner.PreBuildCleanup>

Transform all jobs configuration to YAML

Experiment to convert back jobs generated by JJB (see my Jenkins Job Builder experiments ) into YAML files.

JJW_USERNAME=admin JJW_PASSWORD=xxxx jjwrecker -s http://localhost:8080/

YAML files will be stored in out directory.

Summary

JJW:

  • Transforms freestyle (partially)
  • Cannot tranform Maven jobs, raw xml present in yaml file
  • Cannot tranform Pipeline jobs, raw xml present in yaml file
  • Tranformation of JJB based jobs is not 100%
  • Tranformation of JJB based jobs didn't happen on ArtifactArchiver, JUnitResultArchiver, BuildTimeoutWrapper, xml snippets in YAML file
  • Custom plugins are pain for JJW
  • PreBuildCleanup, PostBuildCleanup are causing JJW to fail
  • JJW is good tool for simple freestyle jobs without many pre-build and post-build actions
  • JJW is worth trying, at least it helps with YAML conversion

Examples of problematic snipets:

    properties:
   - raw:
       xml: |
         <com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty plugin="[email protected]">
         <ownership>
         <ownershipEnabled>true</ownershipEnabled>
         <primaryOwnerId>[email protected]</primaryOwnerId>
         <coownersIds class="sorted-set" />
         </ownership>
         </com.synopsys.arc.jenkins.plugins.ownership.jobs.JobOwnerJobProperty>
   - raw:
       xml: |
         <com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty plugin="[email protected]">
         <optOut>false</optOut>
         </com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty>
   - raw:
       xml: |
         <com.sonyericsson.rebuild.RebuildSettings plugin="[email protected]">
         <autoRebuild>false</autoRebuild>
         <rebuildDisabled>false</rebuildDisabled>
         </com.sonyericsson.rebuild.RebuildSettings>
   publishers:
   - raw:
       xml: |
         <hudson.plugins.descriptionsetter.DescriptionSetterPublisher plugin="[email protected]">
         <regexp />
         <regexpForFailed />
         <description>${EAP_VERSION}</description>
         <descriptionForFailed>${EAP_VERSION}</descriptionForFailed>
         <setForMatrix>false</setForMatrix>
         </hudson.plugins.descriptionsetter.DescriptionSetterPublisher>