Skip to content

Commit

Permalink
Add tests.skip option for Gradle based plugins too
Browse files Browse the repository at this point in the history
Adapt documentation to meet the structure as in `buildPlugin`.

Fix Asciidoc notation using list continuation `+` character,
so that the lists are rendered correctly (indentation).
  • Loading branch information
darxriggs committed Dec 24, 2019
1 parent 67a3606 commit 14ca5fe
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 16 deletions.
39 changes: 24 additions & 15 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ buildPlugin()
* `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
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).
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:
many cases, `configurations` permit to provide a specific combinations of label and java/jenkins versions to use
+
[source,groovy]
----
buildPlugin(/*...*/, configurations: [
Expand All @@ -48,18 +48,17 @@ buildPlugin(/*...*/, configurations: [
])
----

** It is also possible to use a `buildPlugin.recommendedConfigurations()` method to get recommended configurations for testing.
Note that the recommended configuration may change over time,
** It is also possible to use a `buildPlugin.recommendedConfigurations()` method to get recommended configurations for testing.
Note that the recommended configuration may change over time,
and hence your CI may break if the new recommended configuration is not compatible

+
[source,groovy]
----
buildPlugin(/*...*/, configurations: buildPlugin.recommendedConfigurations())
----


* `tests`: (default: `null`) - a map of parameters to run tests during the build
** `skip` - If `true`, skipp all the tests by setting the `-skipTests` profile.
** `skip` - If `true`, skip all the tests by setting the `-skipTests` profile.
It will also skip FindBugs in modern Plugin POMs.
* `findbugs`: (default: `null`) - a map of parameters to run findbugs and/or archive findbugs reports. (only available for Maven projects)
** `run`: set to `true` to add the `findbugs:findbugs` goal to the maven command.
Expand Down Expand Up @@ -88,7 +87,7 @@ buildPlugin(platforms: ['linux'], jdkVersions: [7, 8], findbugs: [archive: true,
=== buildPluginWithGradle()

Builds a Jenkins plugin using Gradle.
The implementation follows the standard build/test/archive pattern.
The implementation follows the standard build/test/archive pattern.
The method targets compatibility with link:https://github.com/jenkinsci/gradle-jpi-plugin[Gradle JPI Plugin],
and it may not work for other use-cases.

Expand All @@ -99,15 +98,12 @@ and it may not work for other use-cases.
* `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
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
** It is also possible to use a `buildPlugin.recommendedConfigurations()` method to get recommended configurations for testing.
Note that the recommended configuration may change over time,
and hence your CI may break if the new recommended configuration is not compatible
* `timeout`: (default: `60`) - the number of minutes for build timeout, cannot be bigger than 180, i.e. 3 hours.
+
[source,groovy]
----
buildPluginWithGradle(/*...*/, configurations: [
Expand All @@ -116,6 +112,19 @@ buildPluginWithGradle(/*...*/, configurations: [
])
----

** It is also possible to use a `buildPlugin.recommendedConfigurations()` method to get recommended configurations for testing.
Note that the recommended configuration may change over time,
and hence your CI may break if the new recommended configuration is not compatible
+
[source,groovy]
----
buildPluginWithGradle(/*...*/, configurations: buildPlugin.recommendedConfigurations())
----

* `tests`: (default: `null`) - a map of parameters to run tests during the build
** `skip` - If `true`, skip all the tests.
* `timeout`: (default: `60`) - the number of minutes for build timeout, cannot be bigger than 180, i.e. 3 hours.

==== Limitations

Not all features of `buildPlugin()` for Maven are supported in the gradle flow.
Expand Down
3 changes: 3 additions & 0 deletions vars/buildPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ def call(Map params = [:]) {
'cleanTest',
'build',
]
if (skipTests) {
gradleOptions += '--exclude-task test'
}
command = "gradlew ${gradleOptions.join(' ')}"
if (isUnix()) {
command = "./" + command
Expand Down
6 changes: 5 additions & 1 deletion vars/buildPluginWithGradle.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ def call(Map params = [:]) {
String javaLevel = config.javaLevel

String stageIdentifier = "${label}-${jdk}${jenkinsVersion ? '-' + jenkinsVersion : ''}"

boolean skipTests = params?.tests?.skip

tasks[stageIdentifier] = {
node(label) {
timeout(timeoutValue) {
Expand All @@ -55,6 +56,9 @@ def call(Map params = [:]) {
'cleanTest',
'build',
]
if (skipTests) {
gradleOptions += '--exclude-task test'
}
String command = "gradlew ${gradleOptions.join(' ')}"
if (isUnix()) {
command = "./" + command
Expand Down

0 comments on commit 14ca5fe

Please sign in to comment.