aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java29
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java11
-rw-r--r--src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly2
-rw-r--r--src/test/java/BitbucketBuildFilterTest.java6
-rw-r--r--src/test/java/BitbucketBuildRepositoryTest.java9
5 files changed, 20 insertions, 37 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
index 10d6c98..81b5603 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger.java
@@ -28,11 +28,6 @@ import static com.cloudbees.plugins.credentials.CredentialsMatchers.instanceOf;
* Created by nishio
*/
public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> {
- /**
- * Default value for {@link #getCommentTrigger()}.
- */
- public static final String DEFAULT_COMMENT_TRIGGER = "test this please";
-
private static final Logger logger = Logger.getLogger(BitbucketBuildTrigger.class.getName());
private final String projectPath;
private final String cron;
@@ -55,30 +50,6 @@ public class BitbucketBuildTrigger extends Trigger<AbstractProject<?, ?>> {
@Extension
public static final BitbucketBuildTriggerDescriptor descriptor = new BitbucketBuildTriggerDescriptor();
- /**
- * Sets {@link #getCommentTrigger()} to {@link #DEFAULT_COMMENT_TRIGGER}.
- */
- @DataBoundConstructor
- public BitbucketBuildTrigger(
- String projectPath,
- String cron,
- String credentialsId,
- String username,
- String password,
- String repositoryOwner,
- String repositoryName,
- String branchesFilter,
- boolean branchesFilterBySCMIncludes,
- String ciKey,
- String ciName,
- String ciSkipPhrases,
- boolean checkDestinationCommit,
- boolean approveIfSuccess
- ) throws ANTLRException {
- this(projectPath, cron, credentialsId, username, password, repositoryOwner, repositoryName,
- branchesFilter, branchesFilterBySCMIncludes, ciKey, ciName, ciSkipPhrases,
- checkDestinationCommit, approveIfSuccess, DEFAULT_COMMENT_TRIGGER);
- }
@DataBoundConstructor
public BitbucketBuildTrigger(
String projectPath,
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
index ee11e75..01da88e 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
@@ -38,6 +38,10 @@ public class BitbucketRepository {
private static final String BUILD_REQUEST_DONE_MARKER = "ttp build flag";
private static final String BUILD_REQUEST_MARKER_TAG_SINGLE_RX = "\\#[\\w\\-\\d]+";
private static final String BUILD_REQUEST_MARKER_TAGS_RX = "\\[bid\\:\\s?(.*)\\]";
+ /**
+ * Default value for comment trigger.
+ */
+ public static final String DEFAULT_COMMENT_TRIGGER = "test this please";
private String projectPath;
private BitbucketPullRequestsBuilder builder;
@@ -182,7 +186,12 @@ public class BitbucketRepository {
}
private boolean isTTPComment(String content) {
- return content.toLowerCase().contains(trigger.getCommentTrigger().toLowerCase());
+ // special case: in unit tests, trigger is null and can't be mocked
+ String commentTrigger = DEFAULT_COMMENT_TRIGGER;
+ if(trigger != null && StringUtils.isNotBlank(trigger.getCommentTrigger())) {
+ commentTrigger = trigger.getCommentTrigger();
+ }
+ return content.toLowerCase().contains(commentTrigger);
}
private boolean isTTPCommentBuildTags(String content) {
diff --git a/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly b/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly
index 0992564..5f7c37c 100644
--- a/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly
+++ b/src/main/resources/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuildTrigger/config.jelly
@@ -39,6 +39,6 @@
<f:checkbox />
</f:entry>
<f:entry title="Comment phrase to trigger build" field="commentTrigger">
- <f:textbox />
+ <f:textbox default="test this please"/>
</f:entry>
</j:jelly>
diff --git a/src/test/java/BitbucketBuildFilterTest.java b/src/test/java/BitbucketBuildFilterTest.java
index 3a94c82..2bc03fa 100644
--- a/src/test/java/BitbucketBuildFilterTest.java
+++ b/src/test/java/BitbucketBuildFilterTest.java
@@ -1,5 +1,7 @@
+import antlr.ANTLRException;
import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketBuildFilter;
+import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketBuildTrigger;
import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketCause;
import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketPullRequestsBuilder;
import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketRepository;
@@ -194,8 +196,8 @@ public class BitbucketBuildFilterTest {
@Test
@WithoutJenkins
- public void filterPRComments() {
- BitbucketPullRequestsBuilder builder = EasyMock.createMock(BitbucketPullRequestsBuilder.class);
+ public void filterPRComments() throws ANTLRException {
+ BitbucketPullRequestsBuilder builder = EasyMock.createMock(BitbucketPullRequestsBuilder.class);
EasyMock.expect(builder.getTrigger()).andReturn(null).anyTimes();
EasyMock.replay(builder);
diff --git a/src/test/java/BitbucketBuildRepositoryTest.java b/src/test/java/BitbucketBuildRepositoryTest.java
index 953bd81..7a338a7 100644
--- a/src/test/java/BitbucketBuildRepositoryTest.java
+++ b/src/test/java/BitbucketBuildRepositoryTest.java
@@ -118,7 +118,8 @@ public class BitbucketBuildRepositoryTest {
"", true,
"", "", "",
true,
- true
+ true,
+ BitbucketRepository.DEFAULT_COMMENT_TRIGGER
);
BitbucketPullRequestsBuilder builder = EasyMock.createMock(BitbucketPullRequestsBuilder.class);
@@ -148,7 +149,7 @@ public class BitbucketBuildRepositoryTest {
"", true,
"", "", "",
true,
- true
+ true, BitbucketRepository.DEFAULT_COMMENT_TRIGGER
);
BitbucketPullRequestsBuilder builder = EasyMock.createMock(BitbucketPullRequestsBuilder.class);
@@ -202,7 +203,7 @@ public class BitbucketBuildRepositoryTest {
"", true,
"jenkins", "Jenkins", "",
true,
- true
+ true, BitbucketRepository.DEFAULT_COMMENT_TRIGGER
);
BitbucketPullRequestsBuilder builder = EasyMock.createMock(BitbucketPullRequestsBuilder.class);
@@ -248,7 +249,7 @@ public class BitbucketBuildRepositoryTest {
"", true,
"jenkins-too-long-ci-key", "Jenkins", "",
true,
- true
+ true, BitbucketRepository.DEFAULT_COMMENT_TRIGGER
);
final MessageDigest MD5 = MessageDigest.getInstance("MD5");