visualphoenix / jenkins-xml-to-jobdsl

Translates jenkins xml jobs into jobdsl groovy using ruby and nokogiri
Apache License 2.0
44 stars 16 forks source link

Make it possibly to specify indentation level #7

Closed esjee closed 8 years ago

esjee commented 8 years ago

Fixes #3

Example usage:

$ ruby jenkins-xml-to-jobdsl.rb tests/pipeline-example/config.xml -h  
Usage: ruby jenkins-xml-to-jobdsl.rb [OPTIONS] path/to/config.xml
    -i, --indent=indentation_level   Indentation level (default 4)
$ ruby jenkins-xml-to-jobdsl.rb tests/pipeline-example/config.xml -i 1
tests/pipeline-example/config.xml
pipelineJob('pipeline-example') {
 keepDependencies(false)
 properties {
 }
 definition {
  cpsScm {
   scm {
    git {
     remote {
      url('https://github.com/kitconcept/jenkins-pipeline-examples.git')
     }
     branches(['*/master'])
     extensions {
     }
    }
   }
   scriptPath(scriptpath = 'Jenkinsfile')
  }
 }
 triggers {
 }
}
$ ruby jenkins-xml-to-jobdsl.rb tests/pipeline-example/config.xml -i 4
tests/pipeline-example/config.xml
pipelineJob('pipeline-example') {
    keepDependencies(false)
    properties {
    }
    definition {
        cpsScm {
            scm {
                git {
                    remote {
                        url('https://github.com/kitconcept/jenkins-pipeline-examples.git')
                    }
                    branches(['*/master'])
                    extensions {
                    }
                }
            }
            scriptPath(scriptpath = 'Jenkinsfile')
        }
    }
    triggers {
    }
}
$ ruby jenkins-xml-to-jobdsl.rb tests/pipeline-example/config.xml -i 8
tests/pipeline-example/config.xml
pipelineJob('pipeline-example') {
        keepDependencies(false)
        properties {
        }
        definition {
                cpsScm {
                        scm {
                                git {
                                        remote {
                                                url('https://github.com/kitconcept/jenkins-pipeline-examples.git')
                                        }
                                        branches(['*/master'])
                                        extensions {
                                        }
                                }
                        }
                        scriptPath(scriptpath = 'Jenkinsfile')
                }
        }
        triggers {
        }
}
$ ruby jenkins-xml-to-jobdsl.rb tests/pipeline-example/config.xml -i 4
tests/pipeline-example/config.xml
pipelineJob('pipeline-example') {
    keepDependencies(false)
    properties {
    }
    definition {
        cpsScm {
            scm {
                git {
                    remote {
                        url('https://github.com/kitconcept/jenkins-pipeline-examples.git')
                    }
                    branches(['*/master'])
                    extensions {
                    }
                }
            }
            scriptPath(scriptpath = 'Jenkinsfile')
        }
    }
    triggers {
    }
}
visualphoenix commented 8 years ago

Closes #3