From 5713cad30b711181accea3df1893b0b4efc10627 Mon Sep 17 00:00:00 2001 From: Martin Damovsky Date: Wed, 1 Mar 2017 20:04:38 +0100 Subject: [maven-release-plugin] prepare release bitbucket-pullrequest-builder-1.4.25 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 95d6524..08d2d69 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ bitbucket-pullrequest-builder Bitbucket Pullrequest Builder Plugin - 1.4.25-SNAPSHOT + 1.4.25 This Jenkins plugin builds pull requests from Bitbucket.org and will report the test results. hpi https://wiki.jenkins-ci.org/display/JENKINS/Bitbucket+pullrequest+builder+plugin @@ -17,7 +17,7 @@ scm:git:ssh://git@github.com/jenkinsci/bitbucket-pullrequest-builder-plugin.git scm:git:ssh://git@github.com/jenkinsci/bitbucket-pullrequest-builder-plugin.git https://github.com/jenkinsci/bitbucket-pullrequest-builder-plugin.git - HEAD + bitbucket-pullrequest-builder-1.4.25 -- cgit v1.2.3 From bca993a7cabdf6501bcf08438892b8e4d63d37c3 Mon Sep 17 00:00:00 2001 From: Martin Damovsky Date: Wed, 1 Mar 2017 20:04:48 +0100 Subject: [maven-release-plugin] prepare for next development iteration --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 08d2d69..ba1d9c2 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ bitbucket-pullrequest-builder Bitbucket Pullrequest Builder Plugin - 1.4.25 + 1.4.26-SNAPSHOT This Jenkins plugin builds pull requests from Bitbucket.org and will report the test results. hpi https://wiki.jenkins-ci.org/display/JENKINS/Bitbucket+pullrequest+builder+plugin @@ -17,7 +17,7 @@ scm:git:ssh://git@github.com/jenkinsci/bitbucket-pullrequest-builder-plugin.git scm:git:ssh://git@github.com/jenkinsci/bitbucket-pullrequest-builder-plugin.git https://github.com/jenkinsci/bitbucket-pullrequest-builder-plugin.git - bitbucket-pullrequest-builder-1.4.25 + HEAD -- cgit v1.2.3 From ee9f820ef54427a0eadc44f4e8f0d1d6e2f44ef0 Mon Sep 17 00:00:00 2001 From: Nathanial Woolls Date: Wed, 17 May 2017 13:00:24 -0400 Subject: Fix NullPointerException when a Pull Request's destination commit is NULL * see: https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/119 * see: https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/98 --- .../BitbucketRepository.java | 25 +++++-- src/test/java/BitbucketBuildRepositoryTest.java | 84 +++++++++++++++++++++- 2 files changed, 103 insertions(+), 6 deletions(-) diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java index 02d11c5..352ec04 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java @@ -291,17 +291,34 @@ public class BitbucketRepository { } private boolean isFilteredBuild(Pullrequest pullRequest) { + + final String pullRequestId = pullRequest.getId(); + final String pullRequestTitle = pullRequest.getTitle(); + final String destinationRepoName = pullRequest.getDestination().getRepository().getRepositoryName(); + + // pullRequest.getDestination().getCommit() may return null for pull requests with merge conflicts + // * see: https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/119 + // * see: https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/98 + final String destinationCommitHash; + if (pullRequest.getDestination().getCommit() == null) { + logger.log(Level.INFO, "Pull request #{0} ''{1}'' in repo ''{2}'' has a null value for destination commit.", + new Object[]{pullRequestId, pullRequestTitle, destinationRepoName}); + destinationCommitHash = null; + } else { + destinationCommitHash = pullRequest.getDestination().getCommit().getHash(); + } + BitbucketCause cause = new BitbucketCause( pullRequest.getSource().getBranch().getName(), pullRequest.getDestination().getBranch().getName(), pullRequest.getSource().getRepository().getOwnerName(), pullRequest.getSource().getRepository().getRepositoryName(), - pullRequest.getId(), + pullRequestId, pullRequest.getDestination().getRepository().getOwnerName(), - pullRequest.getDestination().getRepository().getRepositoryName(), - pullRequest.getTitle(), + destinationRepoName, + pullRequestTitle, pullRequest.getSource().getCommit().getHash(), - pullRequest.getDestination().getCommit().getHash(), + destinationCommitHash, pullRequest.getAuthor().getCombinedUsername() ); diff --git a/src/test/java/BitbucketBuildRepositoryTest.java b/src/test/java/BitbucketBuildRepositoryTest.java index f076c4d..02e58f0 100644 --- a/src/test/java/BitbucketBuildRepositoryTest.java +++ b/src/test/java/BitbucketBuildRepositoryTest.java @@ -6,6 +6,7 @@ import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketPullRequ import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.BitbucketRepository; import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.ApiClient; +import bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket.Pullrequest; import com.cloudbees.plugins.credentials.CredentialsProvider; import com.cloudbees.plugins.credentials.CredentialsScope; import com.cloudbees.plugins.credentials.CredentialsStore; @@ -18,8 +19,10 @@ import com.google.common.collect.Collections2; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.List; import java.util.logging.Logger; import org.easymock.*; import org.junit.Test; @@ -29,7 +32,6 @@ import org.junit.Assert; import org.jvnet.hudson.test.JenkinsRule; import jenkins.model.Jenkins; -import org.jvnet.hudson.test.WithoutJenkins; import org.apache.commons.codec.binary.Hex; import org.apache.commons.httpclient.Credentials; @@ -106,7 +108,7 @@ public class BitbucketBuildRepositoryTest { @Rule public JenkinsRule jRule = new JenkinsRule(); - + @Test public void repositorySimpleUserPasswordTest() throws Exception { BitbucketBuildTrigger trigger = new BitbucketBuildTrigger( @@ -271,4 +273,82 @@ public class BitbucketBuildRepositoryTest { assertFalse(buildStatusKey.startsWith("jenkins-")); assertEquals((new SHA1HasherFunction(SHA1)).apply("jenkins-too-long-ci-key" + "-" + builder.getProjectId()), buildStatusKey); } + + @Test + public void getTargetPullRequestsWithNullDestinationCommit() throws Exception { + // arrange + + // setup mock BitbucketBuildTrigger + final BitbucketBuildTrigger trigger = EasyMock.createMock(BitbucketBuildTrigger.class); + EasyMock.expect(trigger.getCiSkipPhrases()).andReturn(""); + EasyMock.expect(trigger.getBranchesFilterBySCMIncludes()).andReturn(false); + EasyMock.expect(trigger.getBranchesFilter()).andReturn(""); + EasyMock.replay(trigger); + + // setup mock BitbucketPullRequestsBuilder + final BitbucketPullRequestsBuilder builder = EasyMock.createMock(BitbucketPullRequestsBuilder.class); + EasyMock.expect(builder.getTrigger()).andReturn(trigger).anyTimes(); + EasyMock.expect(builder.getProjectId()).andReturn("").anyTimes(); + EasyMock.replay(builder); + + // setup PRs to return from mock ApiClient + final Pullrequest pullRequest = new Pullrequest(); + + final Pullrequest.Repository sourceRepo = new Pullrequest.Repository(); + sourceRepo.setFullName("Owner/Name"); + + final Pullrequest.Repository destRepo = new Pullrequest.Repository(); + destRepo.setFullName("Owner/Name"); + + final Pullrequest.Branch sourceBranch = new Pullrequest.Branch(); + sourceBranch.setName("Name"); + + final Pullrequest.Branch destBranch = new Pullrequest.Branch(); + destBranch.setName("Name"); + + final Pullrequest.Commit sourceCommit = new Pullrequest.Commit(); + sourceCommit.setHash("Hash"); + + final Pullrequest.Commit destCommit = null; // the crux of the test + + final Pullrequest.Revision sourceRevision = new Pullrequest.Revision(); + sourceRevision.setBranch(sourceBranch); + sourceRevision.setRepository(sourceRepo); + sourceRevision.setCommit(sourceCommit); + + final Pullrequest.Revision destRevision = new Pullrequest.Revision(); + destRevision.setBranch(destBranch); + destRevision.setRepository(destRepo); + destRevision.setCommit(destCommit); + + final Pullrequest.Author author = new Pullrequest.Author(); + author.setDisplayName("DisplayName"); + author.setUsername("Username"); + + pullRequest.setSource(sourceRevision); + pullRequest.setDestination(destRevision); + pullRequest.setId("Id"); + pullRequest.setTitle("Title"); + pullRequest.setState("OPEN"); + pullRequest.setAutohor(author); + + final List pullRequests = new ArrayList<>(Arrays.asList(pullRequest)); + + // setup mock ApiClient + final ApiClient client = EasyMock.createNiceMock(ApiClient.class); + EasyMock.expect(client.getPullRequests()).andReturn(pullRequests); + EasyMock.replay(client); + + // setup SUT + final BitbucketRepository repo = new BitbucketRepository("", builder); + + // act + repo.init(client); + + // assert + Collection targetPullRequests = repo.getTargetPullRequests(); + + assertEquals(pullRequests.size(), targetPullRequests.size()); + assertEquals(pullRequest, targetPullRequests.iterator().next()); + } } -- cgit v1.2.3 From 5dbd62e5d66ebb577ab51b2cbecb9b7d4439c6d8 Mon Sep 17 00:00:00 2001 From: Nathanial Woolls Date: Wed, 17 May 2017 13:06:19 -0400 Subject: Fix error executing javadoc target - An error has occurred in JavaDocs report generation: error: unexpected text --- .../bitbucketpullrequestbuilder/bitbucket/BuildState.java | 2 +- .../bitbucketpullrequestbuilder/bitbucket/Pullrequest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java index e5c15ef..a3ef1f1 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java @@ -3,7 +3,7 @@ package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket; /** * Valid build states for a pull request * - * @see https://confluence.atlassian.com/bitbucket/buildstatus-resource-779295267.html + * @see "https://confluence.atlassian.com/bitbucket/buildstatus-resource-779295267.html" */ public enum BuildState { FAILED, INPROGRESS, SUCCESSFUL diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java index 7ccad7d..b69805e 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java @@ -11,7 +11,7 @@ import org.codehaus.jackson.annotate.JsonProperty; * POJOs representing the pull-requests extracted from the * JSON response of the Bitbucket API V2. * - * @see https://confluence.atlassian.com/bitbucket/pullrequests-resource-423626332.html#pullrequestsResource-GETaspecificpullrequest + * @see "https://confluence.atlassian.com/bitbucket/pullrequests-resource-423626332.html#pullrequestsResource-GETaspecificpullrequest" */ @JsonIgnoreProperties(ignoreUnknown = true) -- cgit v1.2.3