aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pom.xml4
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java9
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java16
-rw-r--r--src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly5
4 files changed, 30 insertions, 4 deletions
diff --git a/pom.xml b/pom.xml
index 5131ef8..8b7a82e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,9 +6,9 @@
<version>1.509.4</version><!-- which version of Jenkins is this plugin built against? -->
</parent>
- <groupId>bitbucket-pullrequest-builder</groupId>
<artifactId>bitbucket-pullrequest-builder</artifactId>
- <version>1.0-SNAPSHOT</version>
+ <version>1.1-SNAPSHOT</version>
+ <description>This Jenkins plugin builds pull requests from Bitbucket.org and will report the test results.</description>
<packaging>hpi</packaging>
<!-- get every artifact through repo.jenkins-ci.org, which proxies all the artifacts that we need -->
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
index 47d94dc..65777a3 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
@@ -27,6 +27,7 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> {
private final String password;
private final String repositoryOwner;
private final String repositoryName;
+ private final String ciSkipPhrases;
transient private BitbucketPullRequestsBuilder bitbucketPullRequestsBuilder;
@Extension
@@ -39,7 +40,8 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> {
String username,
String password,
String repositoryOwner,
- String repositoryName) throws ANTLRException {
+ String repositoryName,
+ String ciSkipPhrases) throws ANTLRException {
super(cron);
this.projectPath = projectPath;
this.cron = cron;
@@ -47,6 +49,7 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> {
this.password = password;
this.repositoryOwner = repositoryOwner;
this.repositoryName = repositoryName;
+ this.ciSkipPhrases = ciSkipPhrases;
}
public String getProjectPath() {
@@ -73,6 +76,10 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> {
return repositoryName;
}
+ public String getCiSkipPhrases() {
+ return ciSkipPhrases;
+ }
+
@Override
public void start(AbstractProject<?, ?> project, boolean newInstance) {
try {
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
index ec13f38..4889dcf 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
@@ -89,6 +89,9 @@ public class BitbucketRepository {
private boolean isBuildTarget(BitbucketPullRequestResponseValue pullRequest) {
boolean shouldBuild = true;
if (pullRequest.getState() != null && pullRequest.getState().equals("OPEN")) {
+ if (isSkipBuild(pullRequest.getTitle())) {
+ return false;
+ }
BitbucketPullRequestResponseValueRepository destination = pullRequest.getDestination();
String owner = destination.getRepository().getOwnerName();
String repositoryName = destination.getRepository().getRepositoryName();
@@ -116,4 +119,17 @@ public class BitbucketRepository {
}
return shouldBuild;
}
+
+ private boolean isSkipBuild(String pullRequestTitle) {
+ String skipPhrases = this.trigger.getCiSkipPhrases();
+ if (skipPhrases != null) {
+ String[] phrases = skipPhrases.split(",");
+ for(String phrase : phrases) {
+ if (pullRequestTitle.toLowerCase().contains(phrase.trim().toLowerCase())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly b/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly
index 964cc85..5117011 100644
--- a/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly
+++ b/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly
@@ -11,7 +11,10 @@
<f:entry title="RepositoryOwner" field="repositoryOwner">
<f:textbox />
</f:entry>
- <f:entry title="RespositoryName" field="repositoryName">
+ <f:entry title="RespositoryName" field="repositoryName">
+ <f:textbox />
+ </f:entry>
+ <f:entry title="CI Skip Phrases" field="ciSkipPhrases">
<f:textbox />
</f:entry>
</j:jelly> \ No newline at end of file