-
Notifications
You must be signed in to change notification settings - Fork 13
Pipeline extensions
By default, the generated branch seed job just creates the branch pipeline.
In some contexts, some additional steps might need to be added in order to setup additional tools for the branch (like instantiating an Ontrack template for example).
The list of pipeline extensions is defined at global level, at class level or at project level, using the extensions
list. Each item in this list must have:
- an
id
which uniquely identifies the extension - a
dsl
string which contains the DSL fragment to insert into the branch seed job
You can use the YAML "|" to introduce the DSL fragment, in order to be able to type it without any indentation problem (see example below).
A project or a project class can then refer to this extension ID in the pipeline-generator-extensions
list. Several extensions can be referred to.
Declare an extension and a class which refers to it:
extensions:
- id: ontrack
dsl: |
configure { node ->
node / 'builders' / 'net.nemerosa.ontrack.jenkins.OntrackDSLStep' {
'usingText' true
'scriptText' "ontrack.branch(SEED_PROJECT, 'template').instance(SEED_BRANCH, [branch: BRANCH])"
'injectEnvironment' 'SEED_PROJECT,SEED_BRANCH,BRANCH'
'injectProperties' ''
'ontrackLog' true
}
}
classes:
- id: ontrack
pipeline-generator-extensions:
- ontrack
Note the usage of the YAML construct "|" which indicates a raw piece of text.
The DSL snippet defines a call to Ontrack to create a branch from the template
branch on the SEED_PROJECT
project, using SEED_BRANCH
as a name, and branch=BRANCH
as a template parameter.
Remember that
SEED_PROJECT
,SEED_BRANCH
andBRANCH
are injected as environment variables in the branch seed job.
In order to activate this extension:
- either your project defines this class in the Seed configuration, like:
...
projects:
- id: yourproject
project-class: ontrack
- either the
PROJECT_CLASS
parameter is passed to the Seed job, containing theontrack
value.