Skip to content
Damien Coraboeuf edited this page May 27, 2015 · 8 revisions

Generation of pipelines

The branch seed job is responsible for the (re)generation of a branch pipeline.

In the absence of any particular setup, the Seed plug-in will execute any seed/seed.groovy Job DSL script. No additional library is associated to this script and it must run in standalone mode.

Note that if no script is found, nothing will happen at all.

In all cases, the jobs, views and folders defined by this script will be created/updated at the level than the branch seed job.

An item not defined any longer by the DSL script will be deleted.

In case some additional setup is needed, the branch must also declare a seed/seed.properties property file.

The properties are the following:

  • seed.dsl.libraries - a comma-separated list of dependency notations, used to download JAR libraries that can then be referred from the DSL script - it defaults to nothing (empty list)

Note that all transitive dependencies of the declared libraries will also be downloaded.

  • seed.dsl.repository - a URL to a repository to download the libraries from. It defaults to none, meaning that the libraries are downloaded from the Maven Central repository. If the property is prefixed by flat:, the rest of the property is taken as a file path (relative to the seed directory), used as a flat repository
  • seed.dsl.script.jar - defines the library which contains the DSL script to execute. If not defined, the script is assumed to be provided by the branch, directly in seed/seed.groovy
  • seed.dsl.script.location - defines the path to the DSL script in the JAR defined above. It defaults to seed.groovy - see the [documentation](Pipeline library) to know how to define a pipeline library

In all cases, the DSL script is called with the following parameters, injected as variables:

Raw parameters (seed generator input + scm branch):

  • PROJECT - raw project name, like nemerosa/seed in GitHub
  • PROJECT_CLASS
  • PROJECT_SCM_TYPE
  • PROJECT_SCM_URL
  • PROJECT_SCM_CREDENTIALS - UUID of the [Jenkins credentials](SCM credentials) to use
  • BRANCH - basic branch name in the SCM, like branches/xxx in SVN

Computed parameters:

  • SEED_PROJECT - project normalised name
  • SEED_BRANCH - branch normalised name

Use cases and samples

Simple DSL script

In your branch, like for the Seed plugin itself:

seed/
   seed.groovy

With seed.groovy:

freeStyleJob("${SEED_PROJECT}-${SEED_BRANCH}-build") {
    logRotator(-1, 40)
    jdk 'JDK7'
    parameters {
        stringParam('COMMIT', 'HEAD', 'Commit to build')
    }
    scm {
        git {
            remote {
                url "git@github.com:nemerosa/seed-plugin.git"
                branch "origin/${BRANCH}"
            }
            wipeOutWorkspace()
            localBranch "${BRANCH}"
        }
    }
    steps {
        gradle 'clean localDockerAcceptanceTest --info --profile'
    }
    publishers {
        archiveJunit("**/build/test-results/*.xml")
        tasks(
                '**/*.java,**/*.groovy,**/*.xml,**/*.html,**/*.js',
                '**/build/**',
                'FIXME', 'TODO', '@Deprecated', true
        )
    }
}

DSL script with libraries

If your DSL script needs extra dependencies:

seed/
   seed.properties
   seed.groovy

with seed.properties:

seed.dsl.libraries=group:artifact:version

and seed.groovy:

freeStyleJob("${SEED_PROJECT}-${SEED_BRANCH}-build") {
   // Using classes from group:artifact:version
}

Using a template library

seed/
   seed.properties

with seed.properties:

seed.dsl.libraries=group:artifact:version
seed.dsl.script.jar=artifact

The seed.groovy file will be available as a resource in the artifact.jar file.

See also

  • Configuration
  • [SCM credentials](SCM credentials)
  • [Creating a pipeline library](Pipeline library)
Clone this wiki locally