Public Repository

Last pushed: 2 years ago
Short Description
Jenkins server with experimental dsl extensions
Full Description

#Augmented job-dsl for Jenkins

##Run

run docker with this

docker run -d -p 8080:8080 jeremymarshall/jenkins-dsl-stub:latest

(optionally map the port in boot2docker)

--boot2docker only!

VBoxManage controlvm boot2docker-vm natpf1 "name,tcp,127.0.0.1,8080,,8080"

and you should have a Jenkins server on http://localhost:8080

##Available extensions

  • Scm
  • Axis (matrix only)
  • Step
  • Publisher

Other areas can be added with an extension point

##Extensions in plugins

There are extensions to the job-dsl which are detailed in

http://localhost:8080/dsl

//Classes for SCM stage
scm {
    // Plugin:filesystem_scm
    // class hudson.plugins.filesystem_scm.dsl.DslSCM

    // Add a filesystem SCM
    fsscm
        String Source path

    // Add a filesystem SCM
    fsscm
        String Source path,
        String Destination in workspace

    // Add a File System SCM with a closure
    fsscm {
            // class hudson.plugins.filesystem_scm.dsl.DslSCMClosure

            // Clear workspace
            clearWorkspace
                boolean Clear directory before copying

            // Copy hidden files
            copyHidden
                boolean Copy hidden files

            // Filter files
            filter
                String include or exclude,
                String... vaargs of wildcards to add

            // Filter files
            filter
                String include or exclude,
                List<String> list of wildcards to add

            // Set Local Path
            localPath
                String The directory in the workspace to write to

            // Set Path
            path
                String The path to read from
    }
}

//Classes for Matrix Axes
axes {
    // Plugin:chuck-norris-axis
    // class org.jenkinsci.chucknorrisaxis.dsl.Axis

    // Add a chuckNorrisAxis with a closure
    chuckNorris {
            // class org.jenkinsci.chucknorrisaxis.dsl.AxisClosure

            // Axis name
            axisName
                String The name of the axis

            // Add chuckNorrisItems with a closure
            items {
                    // class org.jenkinsci.chucknorrisaxis.dsl.ItemClosure

                    // Populate from Chuck Norris Plugin (if installed)
                    auto()

                    // Populate with (List) manual entries
                    manual
                        List<String> The quotes to add as individual items

                    // Populate with (vaargs) manual entries
                    manual
                        String... The quotes to add as individual axis

            }

    }

    // Add a chuckNorrisAxis with only chucknorrisplugin entries
    chuckNorris
        String Axis name

    // Add a chuckNorrisAxis with chucknorrisplugin and (vaargs) manual entries
    chuckNorrisBoth
        String Axis name,
        String... The quotes to add as individual axis

    // Add a chuckNorrisAxis with chucknorrisplugin and (List) manual entries
    chuckNorrisBoth
        String Axis name,
        List<String> The quotes to add as individual axis

    // Add a chuckNorrisAxis with only manual (List) entries
    chuckNorrisManual
        String Axis name,
        List<String> The quotes to add as individual axis

    // Add a chuckNorrisAxis with only manual (vaargs) entries
    chuckNorrisManual
        String Axis name,
        String... The quotes to add as individual axis

}

//Classes for Publish steps
publishers {
    // Plugin:log-parser
    // class hudson.plugins.logparser.dsl.DslLogParserPublisher

    // Add a log parser with a closure
    logParser {
            // class hudson.plugins.logparser.dsl.DslLogParserPublisherClosure

            // Fail Build On Error
            failBuildOnError
                boolean Fail on error

            // Set parsingRulesPath
            parsingRulesPath
                String The path to the parsing rules

            // Set projectRulePath
            projectRulePath
                String The path to the project parsing rules

            // Show Graphs
            showGraphs
                boolean Show graphs

            // Unstable on warning
            unstableOnWarning
                boolean Is unstable on warning
    }

    // Add a log parser using a project rules file
    logParserGlobal
        String Project rules file

    // Add a log parser using a project rules file
    logParserGlobal
        String Project rules file,
        boolean Is unstable on warning,
        boolean Fail on build error,
        boolean Show graphs

    // Add a log parser using a file in the workspace
    logParserWorkspace
        String Parsing rules file,
        boolean Is unstable on warning,
        boolean Fail on build error,
        boolean Show graphs

    // Add a log parser using a file in the workspace
    logParserWorkspace
        String Parsing rules file
}

//Classes for Build steps
steps {
    // Plugin:hw-dsl-stub
    // class org.jenkinsci.plugins.hw_dsl_stub.HelloWorld

    // Add a helloWorld step with a closure
    helloWorld {
            // class org.jenkinsci.plugins.hw_dsl_stub.HelloWorldClosure

            // Set Hello World Name
            who
                String The name to use in the hello world step

    }

    // Add a helloWorld step
    helloWorld
        String The name to use in the hello world step
}

##Example

This can be used for a job-dsl script like this - which is job dsl in the demo server

job (type: Matrix){
      name 'auto'
      description 'Build and test the app.'
    multiscm{
      fsscm{
        path '/var/tools'
        localPath 'test'
      }
    }

  axes{
    chuckNorris{
      axisName 'Jeremy'
      items {
        manual 'bbb', 'ccc', 'ddd'
        auto()
      }
    }
    text 'ddd', 'a','b','c'
  }
  steps {
    helloWorld {who 'Jeremy'}
    shell('ps')
    shell('env |sort')
  }

  publishers{
    logParser {
      projectRulePath 'test/rules.txt'
    }
  }
}

##Github links
the plugin repos to build this for yourself are

Docker Pull Command
Owner
jeremymarshall

Comments (0)