class PipelineStage extends java.lang.Object
Type | Name and description |
---|---|
static java.util.List |
ALLOWED_IMAGE_PREFIXES Image names must be prefixed by or match one of the following. |
static java.net.URI |
CHARTSREPO |
static java.lang.String |
SETUP |
static java.util.List |
STEPS |
static java.lang.String |
TEARDOWN |
java.util.Map |
config |
java.lang.String |
name |
Pipeline |
pipeline |
Constructor and description |
---|
PipelineStage
(Pipeline pline, java.lang.String stageName, java.util.Map stageConfig, java.lang.Object nodeContext) |
Type Params | Return Type | Name and description |
---|---|---|
|
void |
build(java.lang.Object ws, java.lang.Object runner) Builds the configured Blubber variant. |
|
groovy.lang.Closure |
closure(java.lang.Object ws) Constructs and returns a closure for this pipeline stage using the given Jenkins workflow script object. |
|
void |
copy(java.lang.Object ws, java.lang.Object runner) Copy files from the filesystem of a previously run container. |
|
static java.util.Map |
defaultConfig(java.util.Map cfg) Returns an config based on the given one but with default values inserted. |
|
void |
deploy(java.lang.Object ws, java.lang.Object runner) Deploy a published image to a WMF k8s cluster. |
|
void |
exports(java.lang.Object ws, java.lang.Object runner) Binds a number of new values for reference in subsequent stages. |
|
java.util.Set |
getRequiredNodeLabels() Returns a set of node labels that will be required for this stage to function correctly. |
|
java.util.List |
getReviewers(java.lang.Object ws) |
|
java.lang.Boolean |
hasServiceUserTag(java.lang.Object tags) |
|
void |
notify(java.lang.Object ws, java.lang.Object runner) Notifies folks of stage failure according to the stage or pipeline level configuration. |
|
java.lang.Object |
parseJson(java.lang.Object jsonString) |
|
void |
promote(java.lang.Object ws, java.lang.Object runner) Promote a published artifact (create a patchset to change the image version in the deployment-charts repo). |
|
void |
publish(java.lang.Object ws, java.lang.Object runner) Push a built image variant to the WMF Docker registry. |
|
void |
run(java.lang.Object ws, java.lang.Object runner) Runs the entry point of a built image variant. |
|
void |
setup(java.lang.Object ws, java.lang.Object runner) Performs setup steps, checkout out the repo and binding useful values to be used by all other stages (default image labels, project identifier, timestamp, etc). |
|
void |
teardown(java.lang.Object ws, java.lang.Object runner) Performs teardown steps, removing images and helm releases, and reporting back to Gerrit. |
|
void |
trigger(java.lang.Object ws, java.lang.Object runner) Trigger a downstream job on the local Jenkins server |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Image names must be prefixed by or match one of the following. Note that context variables within these strings are substituted just prior to enforcement.
Builds the configured Blubber variant.
build
build: "foo"
expands to
build: { variant: "foo", context: "." }
variant
{$.stage}
(same as the stage name)context
docker build
"."
excludes
.dockerignore
file being overwritten prior to the build and only has an effect when
the context is a local directory. Patterns must be valid
Docker ignore rules.imagePullPolicy
"always"
or "never"
.
If "always"
, --pull will be passed to docker build
."always"
stages:
- name: candidate
build: production
stages:
- name: build-main-project
build:
variant: build
excludes: [/src/foo]
- name: build-subproject
build:
variant: build-foo
context: src/foo
${[stage].imageID}
${[stage].imageLocalName}
Constructs and returns a closure for this pipeline stage using the given Jenkins workflow script object.
Copy files from the filesystem of a previously run container.
copy
[]
${.container}
(the container that ran
during this stage's run step)source
(the source path made relative to
the local context directory).false
[source, source, ...]
${[stage].artifactURLs}
destination
of the copy was a directory, the artifact at
this URL will be a tar.gz file.Returns an config based on the given one but with default values inserted.
def cfg = [name: "foo"]
assert PipelineStage.defaultConfig(cfg) == [
name: "foo",
build: [
variant: '${.stage}', // builds a variant by the same name
],
run: [
image: '${.imageID}', // runs the variant built by this stage
arguments: [],
credentials: [],
tail: 0,
],
]
def cfg = [name: "foo"]
assert PipelineStage.defaultConfig(cfg) == [
name: "foo",
build: '${.stage}', // builds a variant by the same name
run: [
image: '${.imageID}', // runs the variant built by this stage
arguments: [],
credentials: [],
tail: 0,
],
]
def cfg = [name: "foo", build: "foo", run: true]
assert PipelineStage.defaultConfig(cfg) == [
name: "foo",
build: "foo",
run: [
image: '${.imageID}', // runs the variant built by this stage
arguments: [],
credentials: [],
tail: 0,
],
]
def cfg = [image: true]
def defaults = PipelineStage.defaultConfig(cfg)
// publish.image.id defaults to the previously built image
assert defaults.publish.image.id == '${.imageID}'
// publish.image.name defaults to the project name
assert defaults.publish.image.name == '${setup.project}'
// publish.image.tag defaults to {timestamp}-{stage name}
assert defaults.publish.image.tag == '${setup.timestamp}-${.stage}'
def cfg = [promote: true]
def defaults = PipelineStage.defaultConfig(cfg)
// promote defaults to a map chart, environments, and version.
// The default chart is the project name. The default environments
// are the empty list. The default version is the published inmage tag.
assert defaults == [
[
chart: '${setup.project}',
environments: []
version: "\${.imageTag}"
]
]
Deploy a published image to a WMF k8s cluster. (Currently only the "ci" cluster is supported for testing.)
deploy
${.publishedImage}
(image published in the
publish() of this stage)"ci"
${setup.projectShortName}
${.imageTag}
(The primary tag of image
built in this stage.)${.imageTag}
helm test
against this deploymenttrue
helm install
${[stage].releaseName}
Binds a number of new values for reference in subsequent stages.
exports
stages:
- name: candidate
build: production
exports:
image: '${.imageID}'
tag: '${.imageTag}-my-tag'
- name: published
publish:
image:
id: '${candidate.image}'
tags: ['${candidate.tag}']
${[name].[value]}
Returns a set of node labels that will be required for this stage to function correctly.
Notifies folks of stage failure according to the stage or pipeline level configuration.
notify
[Pipeline] ${setup.projectShortName} ${setup.pipeline}/${.stage} failed
Promote a published artifact (create a patchset to change the image version in the deployment-charts repo).
promote
[${setup.project}]
(project identifier;
see setup())[]
Push a built image variant to the WMF Docker registry.
publish
image
${.imageID}
(image built in this stage)${setup.project}
(project identifier;
see setup())${setup.timestamp}-${.stage}
[${setup.tag}]
The git tag if one has
been pushed. Otherwise, nothing.${[stage].imageName}
${[stage].imageFullName}
${[stage].imageTag}
${[stage].publishedImage}
${.imageFullName}:${.imageTag}
)Runs the entry point of a built image variant.
run
run: true
expands to
run: { image: '${.imageID}' }
(i.e. the image built in this stage)image
{$.imageID}
arguments
[]
tail
${[stage].output}
.0
stages:
- name: test
build: test
run: true
stages:
- name: built
- name: lint
run:
image: '${built.imageID}'
arguments: [lint]
- name: test
run:
image: '${built.imageID}'
arguments: [test]
env:
- MY_VAR: 'Hello'
credentials:
- id: 'sonarid'
name: 'SONAR_API_KEY'
${[stage].output}
tail
is specified, that number of trailing
lines from the output (stdout) of container process.Performs setup steps, checkout out the repo and binding useful values to be used by all other stages (default image labels, project identifier, timestamp, etc).
${setup.pipeline}
${setup.logURL}
${setup.project}
${setup.projectShortName}
${setup.timestamp}
${setup.imageLabels}
jenkins.job
,
jenkins.build
,
ci.project
,
ci.pipeline
${setup.commit}
${setup.branch}
${setup.remote}
${setup.tag}
${setup.FOO}
.Performs teardown steps, removing images and helm releases, and reporting back to Gerrit.
Trigger a downstream job on the local Jenkins server
trigger
true
(the default), then the result of this
step is that of the downstream build (e.g., success, unstable, failure,
not built, or aborted). If false
, then this step succeeds
even if the downstream build is unstable, failed, etc.
true
, wait for completion of the downstream
build before completing this step. Default: false>
Groovy Documentation