diff options
author | S.Nishio <nishio@densan-labs.net> | 2014-04-19 19:10:42 +0900 |
---|---|---|
committer | S.Nishio <nishio@densan-labs.net> | 2014-04-19 19:10:42 +0900 |
commit | 68bf998f6ebf61dcd5b2d9aad765369aeabf714f (patch) | |
tree | 19d78a56c8aba1de872b8abc693039637bef0fc2 /src/main/java | |
parent | c526bc44e9da96e89c0b6cc3a38dcc3dcb99f328 (diff) | |
parent | 66c0756daf276f214061667ce2b47d036eb3fa8a (diff) | |
download | bbprb-68bf998f6ebf61dcd5b2d9aad765369aeabf714f.tar.gz |
Merge pull request #4 from nishio-dens/feature/issue-3
[Issue-3] Ci Skip
Diffstat (limited to 'src/main/java')
2 files changed, 24 insertions, 1 deletions
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; + } } |