Skip to content

Commit

Permalink
add @symbol to be able to easily use the plugin in a declarative pipe…
Browse files Browse the repository at this point in the history
…line (#19)

* add @symbol to be able to easily use the plugin in a declarative pipeline

Signed-off-by: Olivier Lamy <olamy@apache.org>

* add support for incremental

Signed-off-by: Olivier Lamy <olamy@apache.org>

* Revert "add support for incremental"

This reverts commit fdf7661.

* fix incremental

Signed-off-by: Olivier Lamy <olamy@apache.org>

* downgrade incremental extension as it does not work well with Java 8

Signed-off-by: Olivier Lamy <olamy@apache.org>

---------

Signed-off-by: Olivier Lamy <olamy@apache.org>
  • Loading branch information
olamy committed Sep 18, 2023
1 parent 6d46161 commit c472151
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
@@ -0,0 +1,7 @@
<extensions xmlns="http://maven.apache.org/EXTENSIONS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/EXTENSIONS/1.0.0 http://maven.apache.org/xsd/core-extensions-1.0.0.xsd">
<extension>
<groupId>io.jenkins.tools.incrementals</groupId>
<artifactId>git-changelist-maven-extension</artifactId>
<version>1.6</version>
</extension>
</extensions>
2 changes: 2 additions & 0 deletions .mvn/maven.config
@@ -0,0 +1,2 @@
-Pconsume-incrementals
-Pmight-produce-incrementals
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions pom.xml
Expand Up @@ -35,7 +35,7 @@

<artifactId>build-blocker-plugin</artifactId>
<name>Build Blocker Plugin</name>
<version>1.7.9-SNAPSHOT</version>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>
<url>https://github.com/jenkinsci/build-blocker-plugin</url>

Expand All @@ -61,10 +61,10 @@
</developers>

<scm>
<connection>scm:git:https://github.com/jenkinsci/build-blocker-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/build-blocker-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/build-blocker-plugin.git</url>
<tag>HEAD</tag>
<connection>scm:git:https://github.com/${gitHubRepo}.git</connection>
<developerConnection>scm:git:git@github.com:${gitHubRepo}.git</developerConnection>
<url>https://github.com/${gitHubRepo}.git</url>
<tag>${scmTag}</tag>
</scm>

<repositories>
Expand Down Expand Up @@ -94,6 +94,9 @@
</dependencyManagement>

<properties>
<revision>1.7.9</revision>
<changelist>-SNAPSHOT</changelist>
<gitHubRepo>jenkinsci/build-blocker-plugin</gitHubRepo>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bom>2.222.x</bom>
<jenkins.version>2.222.4</jenkins.version>
Expand Down Expand Up @@ -124,6 +127,11 @@
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci</groupId>
<artifactId>symbol-annotation</artifactId>
<version>1.23</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Expand Up @@ -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;

Expand Down Expand Up @@ -84,6 +85,7 @@ public BuildBlockerProperty(boolean useBuildBlocker, String blockLevel, String s
* Descriptor
*/
@Extension
@Symbol("buildBlocker")
public static final class BuildBlockerDescriptor extends JobPropertyDescriptor {

/**
Expand Down

0 comments on commit c472151

Please sign in to comment.