repo (default: null inherit from Multibranch) - custom Git repository to check out
useContainerAgent (default: false) - uses a Container agent instead of a Virtual Machine: usually faster to start and generates less costs for the project
Please note that the implementation of "containers" can be changed over time
useAci (DEPRECATED - see useContainerAgent)
failFast (default: true) - instruct Maven tests to fail fast
platforms (default: ['linux', 'windows']) - Labels matching platforms to
execute the steps against in parallel
jdkVersions (default: [8]) - JDK version numbers, must match a version
number jdk tool installed
jenkinsVersions: (default: [null]) - a matrix of Jenkins baseline versions to build/test against in parallel (null means default,
only available for Maven projects)
configurations: An alternative way to specify platforms, jdkVersions and jenkinsVersions (that can not be combined
with any of them).
Those options will run the build for all combinations of their values. While that is desirable in
many cases, configurations permit to provide a specific combinations of label and java/jenkins versions to use
tests: (default: null) - a map of parameters to run tests during the build. The test results and the JaCoCo code
coverage results are recorded after the build with the corresponding Jenkins plugins.
skip - If true, skip all the tests by setting the -skipTests profile.
It will also skip FindBugs in modern Plugin POMs.
spotbugs, checkstyle, pmd, cpd: (default: null) - a map of parameters to archive SpotBugs, CheckStyle, PMD, or CPD warnings, respectively (only available for Maven projects).
These values can replace or amend the default configuration for the recordIssues step of the Warnings NG Plugin.
See Warnings NG Plugin documentation
for a list of available configuration parameters.
timeout: (default: 60) - the number of minutes for build timeout, cannot be bigger than 180, i.e. 3 hours.
Note
The recordIssues steps of the warnings plugin run on the first platform/jdkVersion,jenkinsVersion combination only.
So in the example below it will run for linux/jdk7 but not on jdk8.
Builds a Jenkins plugin using Gradle.
The implementation follows the standard build/test/archive pattern.
The method targets compatibility with Gradle JPI Plugin,
and it may not work for other use-cases.
Optional arguments
repo (default: null inherit from Multibranch) - custom Git repository to check out
failFast (default: true) - instruct the build to fail fast when one of the configurations fail
platforms (default: ['linux', 'windows']) - Labels matching platforms to
execute the steps against in parallel
jdkVersions (default: [8]) - JDK version numbers, must match a version
number jdk tool installed
configurations: An alternative way to specify platforms, jdkVersions (that can not be combined
with any of them)
Those options will run the build for all combinations of their values. While that is desirable in
many cases, configurations permit to provide a specific combinations of label and java/jenkins versions to use
Determine whether the Pipeline is executing in an internal "trusted" Jenkins
environment
Jenkinsfile
if (infra.isTrusted()) {
/* perform some trusted action like a deployment */
}
infra.ensureInNode(nodeLabels, body)
Ensures that the given code block is runs in a node with the specified labels
Jenkinsfile
infra.ensureInNode('docker,java') {
sh 'docker -v'
}
infra.stashJenkinsWar(jenkins, stashName)
Given a version of jenkins downloads it if necessary and stashes it under the given name (which defaults to "jenkinsWar",
see the step doc for more documentation about he allowed versions
The configuration is divided into two parts, one related to the step itself and another related to how the ATH is run.
To configure the step just use the step’s parameters described below, to configure the ATH runs a metadata file (in YAML format)
is used. Further sections describe the metadata file in detail. Note that if the metadata file does not exist this step
will do nothing at all.
The list of step’s params and the related default values are:
athUrl
The URL to get the ATH sources. It can point to a local path (by using the file:// protocol) or a github destination. Defaults to https://github.com/jenkinsci/acceptance-test-harness.git. Can be overridden from the metadata file
athRevision
The ATH revision to use, can be a branch or tag name or a commit id. Defaults to branch master. Can be overridden from the metadata file
athImage
The docker image used for the environment where to run the ATH. Defaults to "jenkins/ath". Use "local" to build the image directly from the ATH sources. Can be overridden from the metadata file
metadataFile
A String indicating the file path (relative to where this step is executed) to use as metadata file for the build, more details about the metadata file are provided belows. Defaults to essentials.yml at the location where this step is invoked
jenkins
URI to the jenkins.war, Jenkins version or one of "latest", "latest-rc", "lts" and "lts-rc". Defaults to "latest". For local war files use the file:// protocol in the URI. Can be overridden from the metadata file
jdks
Java versions to use when running ATH. Defaults to 8. Only 8 and 11 are supported. Can be overridden from the metadata file
configFile
(Optional) Relative (to the workspace) path of a groovy script to customize the ATH behaviour
.Step call example
To make it usable in PR builders this step allows users to run the ATH using custom (typically previously built in the same Jenkinsfile) versions of any plugin, for that you need to set the metadata file’s useLocalSnapshots property to true and stash the
plugins you want to use in the ATH run. By default you need to stash them with the name localPlugins the step will unstash them when appropriate and use the ATH`s LOCAL_JARS property to run the ATH. You can stash any number of plugins, all of
them will be used. You can also stash under other name by setting the env variable RUN_ATH_LOCAL_PLUGINS_STASH_NAME
(Optional) The URL to get the ATH sources. It can point to a local path or a github destination. If specified it will override the parameter in the runATH step
athRevision
(Optional) The ATH revision to use can be a branch or tag name or a commit id. If specified it will override the parameter in the runATH step
athImage
(Optional) The docker image used for the environment where to run the ATH. Defaults to "jenkins/ath". Use "local" to build the image directly from the ATH sources.
jenkins
(Optional) URI to the jenkins.war file, Jenkins version or one of "latest", "latest-rc", "lts" and "lts-rc". If specified it will override the parameter in the runATH step
failFast
If the run has to fail fast or not. Defaults to false if not specified
rerunFailingTestsCount
The number of runs per failing test (a la maven). Defaults to zero
useLocalSnapshots
If the ATH should use local versions of the plugins. Defaults to true. Note that if true the runATH expects the local plugins to be stashed, setting this to true without the stash will make the step fail
browsers
The list of browsers to use when running ATH Defaults to firefox. Note that currently only firefox browser is supported, any other will be ignored
tests
The list of tests to run for the component that calls the step. If no particular set of tests or categories is defined the SmokeTest Category of the ATH will be run
categories
The list of Categories to run. Defaults to nothing
jdks
The list of jdks to use when running ATH. Defaults to 8. Note that currently only 8 and 11 are supported, any other will be ignored
In case you want to use the defaults for all properties you can use
metadata
ath: "default"
Please note that a blank metadata file will result in an error
The configuration is divided into two parts, one related to the step itself and another related to how the PCT is run.
To configure the step just use the step’s parameters described below, to configure the PCT runs a metadata file (in YAML format)
is used. Further sections describe the metadata file in detail. Note that if the metadata file does not exist this step
will do nothing at all.
The list of step’s params and the related default values are:
pctUrl
The URL to get the PCT Dockerfile or the pct docker image to use. It can point to a local path of PCT sources (by using the file:// protocol) or a github destination. You can also use this to directly
specify a prebuilt PCT docker image by using the docker:// protocol, for example "docker://jenkins/pct". Can be overridden from the metadata file
pctRevision
The PCT revision to use in case that pctUrl points to a github destination, can be a branch or tag name or a commit id. Defaults to branch master. Can be overridden from the metadata file
metadataFile
A String indicating the file path (relative to where this step is executed) to use as metadata file for the build, more details about the metadata file are provided belows. Defaults to essentials.yml at the location where this step is invoked
jenkins
URI to the jenkins.war, Jenkins version or one of "latest", "latest-rc", "lts" and "lts-rc". Defaults to "latest". For local war files use the file:// protocol in the URI. Can be overridden from the metadata file
pctExtraOptions
List of extra PCT options to be passed to the PCT executable. Defaults to empty list.
javaOptions
List of extra Java options to be passed to the PCT executable. Defaults to empty list.
dockerOptions
List of extra options to be passed to PCT containers ( e.g. maven-repo:/root/.m2)
jdkVersion
The version of the JDK to use to run the tests. Should be 8 or 11. Defaults to 8.
To make it usable in PR builders this step allows users to run the PCT using custom (typically previously built in the same Jenkinsfile) versions of any plugin, for that you need to set the metadata file’s <i>useLocalSnapshots</i> property to true and stash the
plugins you want to use in the PCT run. By default you need to stash them with the name<i>localPlugins</i> the step will unstash them when appropriate and use the PCT`s docker image <i>/pct/plugin-src</i> volume to access the sources. You can stash any number of plugins, all of
them will be tested as long as they are specified in the metadata file. You can also stash under other name by setting the env variable <i>RUN_PCT_LOCAL_PLUGIN_SOURCES_STASH_NAME</i>
(Optional) The URL to get the PCT Dockerfile or the pct docker image to use. It can point to a local path of PCT sources (by using the file:// protocol) or a github destination. You can also use this to directly
specify a prebuilt PCT docker image by using the docker:// protocol, for example "docker://jenkins/pct".
pctRevision
(Optional) The PCT revision to use in case that pctUrl points to a github destination, can be a branch or tag name or a commit id. Defaults to branch master.
jenkins
(Optional) URI to the jenkins.war file, Jenkins version or one of "latest", "latest-rc", "lts" and "lts-rc". If specified it will override the parameter in the runATH step
useLocalSnapshots
If the ATH should use local versions of the plugins. Defaults to true. Note that if true the runPCT expects the local plugins to be stashed, setting this to true without the stash will make the step fail
plugins
The list of plugins to run, you must specify the artifactID of the plugin. Defaults to nothing
In case you want to use the defaults for all properties you can use
metadata
pct: "default"
Please note that a blank metadata file will result in an error
runBenchmarks
Runs JMH benchmarks and archives benchmark reports on highmem nodes.
Supported parameters:
artifacts
(Optional) If artifacts is not null, invokes archiveArtifacts with the given string value.
Example
runBenchmarks('jmh-report.json')
buildDockerAndPublishImage(imageName, config)
Lints, Builds, then publishes a docker image.
Adds a bunch of build args you can use in your docker image:
GIT_COMMIT_REV - The commit that triggered this build
GIT_SCM_URL - Url to repo
BUILD_DATE - Date that the image was built (now)
Supported parameters:
imageName
Name of the docker image to build
configs
(Optional) extra flags
registry: override the smart default of jenkinsciinfra/ or jenkins4eval/
dockerfile: override the default dockerfile of Dockerfile
Example
buildDockerImage_k8s('plugins-site-api')
Design documents for runATH and runPCT
The design and some more details about the runATH and runPCT steps can be found here
请发表评论