From c472151589710de894ff54a4ab278839b3280c35 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 18 Sep 2023 23:42:05 +1000 Subject: [PATCH] add @Symbol to be able to easily use the plugin in a declarative pipeline (#19) * add @Symbol to be able to easily use the plugin in a declarative pipeline Signed-off-by: Olivier Lamy * add support for incremental Signed-off-by: Olivier Lamy * Revert "add support for incremental" This reverts commit fdf7661f21fff0d849ba9defcde0ec983fb80a33. * fix incremental Signed-off-by: Olivier Lamy * downgrade incremental extension as it does not work well with Java 8 Signed-off-by: Olivier Lamy --------- Signed-off-by: Olivier Lamy --- .mvn/extensions.xml | 7 +++++++ .mvn/maven.config | 2 ++ README.md | 15 +++++++++++++++ pom.xml | 18 +++++++++++++----- .../buildblocker/BuildBlockerProperty.java | 2 ++ 5 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 .mvn/extensions.xml create mode 100644 .mvn/maven.config diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml new file mode 100644 index 0000000..90787cb --- /dev/null +++ b/.mvn/extensions.xml @@ -0,0 +1,7 @@ + + + io.jenkins.tools.incrementals + git-changelist-maven-extension + 1.6 + + diff --git a/.mvn/maven.config b/.mvn/maven.config new file mode 100644 index 0000000..2a0299c --- /dev/null +++ b/.mvn/maven.config @@ -0,0 +1,2 @@ +-Pconsume-incrementals +-Pmight-produce-incrementals diff --git a/README.md b/README.md index faffc34..f661173 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,21 @@ Either buildable builds can stop another build from running (for instance all planned builds can stop another build from running (blocked builds, pending builds waiting builds and buildable builds) +## Declarative Pipeline + +Inside a declarative pipeline, this can be used as is: + +``` +pipeline { + agent any + + options { + buildBlocker (useBuildBlocker: true, blockLevel: 'NODE', scanQueueFor: 'ALL', blockingJobs: 'foo-.*') + } + .... +} +``` + ## JobDSL Usage inside jobdsl scripts is simple as well. For example in order to create a pipeline job which blocks on global level diff --git a/pom.xml b/pom.xml index 5bda56f..116b111 100644 --- a/pom.xml +++ b/pom.xml @@ -35,7 +35,7 @@ build-blocker-plugin Build Blocker Plugin - 1.7.9-SNAPSHOT + ${revision}${changelist} hpi https://github.com/jenkinsci/build-blocker-plugin @@ -61,10 +61,10 @@ - scm:git:https://github.com/jenkinsci/build-blocker-plugin.git - scm:git:git@github.com:jenkinsci/build-blocker-plugin.git - https://github.com/jenkinsci/build-blocker-plugin.git - HEAD + scm:git:https://github.com/${gitHubRepo}.git + scm:git:git@github.com:${gitHubRepo}.git + https://github.com/${gitHubRepo}.git + ${scmTag} @@ -94,6 +94,9 @@ + 1.7.9 + -SNAPSHOT + jenkinsci/build-blocker-plugin UTF-8 2.222.x 2.222.4 @@ -124,6 +127,11 @@ org.jenkins-ci.plugins matrix-project + + org.jenkins-ci + symbol-annotation + 1.23 + org.mockito mockito-core diff --git a/src/main/java/hudson/plugins/buildblocker/BuildBlockerProperty.java b/src/main/java/hudson/plugins/buildblocker/BuildBlockerProperty.java index d6f088c..4e2003f 100644 --- a/src/main/java/hudson/plugins/buildblocker/BuildBlockerProperty.java +++ b/src/main/java/hudson/plugins/buildblocker/BuildBlockerProperty.java @@ -30,6 +30,7 @@ import hudson.model.JobPropertyDescriptor; import hudson.util.FormValidation; import org.apache.commons.lang.StringUtils; +import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; @@ -84,6 +85,7 @@ public BuildBlockerProperty(boolean useBuildBlocker, String blockLevel, String s * Descriptor */ @Extension + @Symbol("buildBlocker") public static final class BuildBlockerDescriptor extends JobPropertyDescriptor { /**