Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-16360

Print DSL formatted config.xml for an existing Job

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Major Major
    • job-dsl-plugin
    • None

      Reading and translating the config.xml of a desired project isn't exactly easy. It'd be pretty straightforward to print the config.xml for a job in the DSL format. I'm thinking a button on the left of a Job, which registers itself as a URL (common Jenkins practice).

      Comments from original Github Issue

      andrewharmellaw commented 8 months ago
      Simple and easy and expected is good, at least for a starter. I'd go with this as you propose for R1

          [JENKINS-16360] Print DSL formatted config.xml for an existing Job

          Brantone added a comment -

          +1 ... converting existing job to DSL would be great.

          Brantone added a comment - +1 ... converting existing job to DSL would be great.

          http://job-dsl.herokuapp.com/ ?

          We also generate all config.xml in gradle by executing javaposse.jobdsl.Run and passing in our dsl files.

          Christian Bremer added a comment - http://job-dsl.herokuapp.com/ ? We also generate all config.xml in gradle by executing javaposse.jobdsl.Run and passing in our dsl files.

          Brantone added a comment - - edited

          That's pretty sweet but still does Groovy/DSL => XML ... rather than XML => DSL

          Brantone added a comment - - edited That's pretty sweet but still does Groovy/DSL => XML ... rather than XML => DSL

          My bad, I misunderstood the issue.

          +1 for adding support for this.

          Christian Bremer added a comment - My bad, I misunderstood the issue. +1 for adding support for this.

          Christian Bremer added a comment - 300$ is up for grabs for solving this issue at: https://freedomsponsors.org/issue/622/print-dsl-formatted-configxml-for-an-existing-job?alert=SPONSOR#

          ki82 It appears someone recently submitted a solution for this (after it expired). Is there code working or have you not had a chance to check?

          Ethan Spoelstra added a comment - ki82 It appears someone recently submitted a solution for this (after it expired). Is there code working or have you not had a chance to check?

          dragon788 I have not tried the solution, feel free to check it out.

          Christian Bremer added a comment - dragon788 I have not tried the solution, feel free to check it out.

          Wasn't too bad to implement. Works for the 350 jobs I have access to so far. https://github.com/visualphoenix/jenkins-xml-to-jobdsl

          Raymond Barbiero added a comment - Wasn't too bad to implement. Works for the 350 jobs I have access to so far. https://github.com/visualphoenix/jenkins-xml-to-jobdsl

          Frank added a comment - - edited

          visualphoenix thanks for sharing your solution! But it seems to support only some of the job definition features. 

          I struggled several times to find a jobDSL equivalent to what I can easily configure in the job UI, e.g. 
          suppressAutomaticTriggering in jobDSL is not working. 
           
          I would prefer the jobDSL leverage the support on a higher level. In the GUI of a job configuration a button can print out the jobDSL of this job configuration. This would save me several hours to find the equivalent in the jobDSL. 
           
          The Jenksinfile DSL do this already with the snippet generator. The jobDSL would with this improvement come to a first class citizen in Jenksins, I think. It would bring the jobDSL to a enterprise level. 

          The job-dsl/api-viewer is not enough, because the mapping from UI to the api viewer items it not trivial. 

          Frank added a comment - - edited visualphoenix thanks for sharing your solution! But it seems to support only some of the job definition features.  I struggled several times to find a jobDSL equivalent to what I can easily configure in the job UI, e.g.  suppressAutomaticTriggering in jobDSL is not working.    I would prefer the jobDSL leverage the support on a higher level. In the GUI of a job configuration a button can print out the jobDSL of this job configuration. This would save me several hours to find the equivalent in the jobDSL.    The Jenksinfile DSL do this already with the snippet generator. The jobDSL would with this improvement come to a first class citizen in Jenksins, I think. It would bring the jobDSL to a enterprise level.  The job-dsl/api-viewer is not enough, because the mapping from UI to the api viewer items it not trivial. 

          Jos Backus added a comment -

          I used this with some success but still needed to add some Groovy code because of missing plugin support.

          https://github.com/tinyspeck/xml-job-to-job-dsl-plugin

          Jos Backus added a comment - I used this with some success but still needed to add some Groovy code because of missing plugin support. https://github.com/tinyspeck/xml-job-to-job-dsl-plugin

            quidryan Justin Ryan
            andrewharmellaw Andrew Harmel-Law
            Votes:
            13 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated: