diff --git a/.gitignore b/.gitignore index 1d97739b7..23830e895 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ work *.iml *.iws *.ipr + +# VSCode +.factorypath diff --git a/docs/USER_GUIDE.adoc b/docs/USER_GUIDE.adoc index da3520c91..816169db2 100644 --- a/docs/USER_GUIDE.adoc +++ b/docs/USER_GUIDE.adoc @@ -2,15 +2,14 @@ [IMPORTANT] ===================================================================== -On April 29th, 2019, link:https://developer.atlassian.com/cloud/bitbucket/bbc-gdpr-api-migration-guide/[Atlassian updated their suite APIs for both Bitbucket and JIRA] to comply with link:https://eugdpr.org[GDPR privacy requirements]. CloudBees has evaluated this change against the CloudBees BitBucket Branch Source plugin and the CloudBees JIRA plugin. +On March 5th, 2020, link:https://confluence.atlassian.com/bitbucketserver/bitbucket-server-7-0-release-notes-990546638.html[Atlassian releases Bitbucket Server 7] which removed some undocumented features with regards to pull requests. -. BitBucket Cloud Pipeline jobs created with "classic" Jenkins are unaffected. -. There is a limited impact to Bitbucket Cloud Pipeline jobs created using Blue Ocean: -.. If you are running Blue Ocean version 1.15.1 or earlier, you will be unable to create or edit BitBucket Cloud Pipeline jobs. -.. Upgrading to Blue Ocean 1.16.0 or later fixes this issue. -.. However, because "owner name" has been removed from the BitBucket REST API, when you edit Bitbucket Cloud Pipelines in the "classic" Jenkins UI, a UUID (instead of human-readable text) is displayed in the "owner" field of the Pipeline. +. BitBucket Server Pipeline jobs can no longer perform a lightweight checkout of the Jenkinsfile if you are using the merge strategy for builds. +.. BitBucket Server no longer stores the merged result of a PR to link:https://jira.atlassian.com/browse/BSERV-12284?focusedCommentId=2389584&[improve performance] +.. BitBucket Server Pipeline jobs will automatically fallback to heavyweight checkout +. BitBucket Server 7.x no longer automatically creates the required refs for pull requests +.. For Bitbucket Server Pipeline jobs to function for pull requests on BitBucket Server 7.x you need to enable "Call Changes api" option in the plugin configuration -We *do not* anticipate any broader user impact. If you encounter a change in behavior that you believe is due to the BitBucket or JIRA API changes, please link:https://support.cloudbees.com/hc/en-us[contact CloudBees Support] for assistance. ===================================================================== [id=bitbucket-sect-intro] @@ -23,6 +22,14 @@ as a multi-branch project source in two different ways: IMPORTANT: This plugin is not compatible with versions of Bitbucket Server previous to 4.0. +[id=bitbucket-server-7] +== BitBucket Server 7 compatibility + +_BitBucket Server 7.x_ is supported but does no longer support lightweight checkout for pull requests when merge strategy is used for build. + +IMPORTANT: In order to have the pull request process working the "Call Changes api" option must be +enabled in _Manage Jenkins_ ยป _Configure System_ + [id=bitbucket-scm-source] == Branches and pull requests auto-discovering diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java index db7a3ee93..0ea844ef7 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketSCMSource.java @@ -641,8 +641,7 @@ class Skip extends IOException { getPullRequestTitleCache() .put(pull.getId(), StringUtils.defaultString(pull.getTitle())); getPullRequestContributorCache().put(pull.getId(), - // TODO get more details on the author - new ContributorMetadataAction(pull.getAuthorLogin(), null, pull.getAuthorEmail())); + new ContributorMetadataAction(pull.getAuthorIdentifier(), pull.getAuthorLogin(), pull.getAuthorEmail())); try { // We store resolved hashes here so to avoid resolving the commits multiple times for (final ChangeRequestCheckoutStrategy strategy : strategies.get(fork)) { diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketPullRequest.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketPullRequest.java index 290999fba..1ad9cb05e 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketPullRequest.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketPullRequest.java @@ -52,10 +52,19 @@ public interface BitbucketPullRequest { String getLink(); + /** + * Despite the name, this is a display name or nickname for the author, not a stable username for login. + */ String getAuthorLogin(); + /** + * Not set in Cloud. + */ String getAuthorEmail(); + /** + * Username or account identifier of the author. + */ String getAuthorIdentifier(); List getReviewers(); diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEvent.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEvent.java index 029915bef..80b24bd6c 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEvent.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEvent.java @@ -71,22 +71,22 @@ private void reconstructMissingData() { BitbucketPullRequestValueRepository source = this.pullRequest.getSource(); if (source != null) { BitbucketCloudRepository sourceRepository = source.getRepository(); - if(sourceRepository != null) { + if (sourceRepository != null) { if (sourceRepository.getScm() == null) { sourceRepository.setScm(repository.getScm()); } if (sourceRepository.getOwner() == null) { - if (sourceRepository.getOwnerName().equals(this.pullRequest.getAuthorLogin())) { + if (!sourceRepository.getOwnerName().equals(repository.getOwnerName())) { // i.e., a fork BitbucketCloudRepositoryOwner owner = new BitbucketCloudRepositoryOwner(); - owner.setUsername(this.pullRequest.getAuthorLogin()); - owner.setDisplayName(this.pullRequest.getAuthorDisplayName()); - if (this.repository.isPrivate()) { - sourceRepository.setPrivate(this.repository.isPrivate()); + owner.setUsername(sourceRepository.getOwnerName()); + owner.setDisplayName(this.pullRequest.getAuthorLogin()); + if (repository.isPrivate()) { + sourceRepository.setPrivate(repository.isPrivate()); } sourceRepository.setOwner(owner); - } else if (sourceRepository.getOwnerName().equals(this.repository.getOwnerName())) { - sourceRepository.setOwner(this.repository.getOwner()); - sourceRepository.setPrivate(this.repository.isPrivate()); + } else { // origin branch + sourceRepository.setOwner(repository.getOwner()); + sourceRepository.setPrivate(repository.isPrivate()); } } } @@ -95,7 +95,7 @@ private void reconstructMissingData() { BitbucketCloudBranch sourceBranch = source.getBranch(); BitbucketCommit sourceCommit = source.getCommit(); if (sourceCommit != null - && sourceBranch != null) { + && sourceBranch != null) { if (sourceBranch.getRawNode() == null) { sourceBranch.setRawNode(source.getCommit().getHash()); } @@ -106,23 +106,23 @@ private void reconstructMissingData() { } BitbucketPullRequestValueDestination destination = this.pullRequest.getDestination(); if (destination != null - && destination.getRepository() != null) { + && destination.getRepository() != null) { if (destination.getRepository().getScm() == null) { destination.getRepository().setScm(repository.getScm()); } if (destination.getRepository().getOwner() == null - && destination.getRepository().getOwnerName() - .equals(repository.getOwnerName())) { + && destination.getRepository().getOwnerName() + .equals(repository.getOwnerName())) { destination.getRepository().setOwner(repository.getOwner()); destination.getRepository().setPrivate(repository.isPrivate()); } } if (destination != null - && destination.getCommit() != null - && destination.getBranch() != null - && destination.getBranch().getRawNode() == null) { + && destination.getCommit() != null + && destination.getBranch() != null + && destination.getBranch().getRawNode() == null) { destination.getBranch() - .setRawNode(destination.getCommit().getHash()); + .setRawNode(destination.getCommit().getHash()); } } } diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/pullrequest/BitbucketPullRequestValue.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/pullrequest/BitbucketPullRequestValue.java index cccc766cd..17aa1d3c3 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/pullrequest/BitbucketPullRequestValue.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/client/pullrequest/BitbucketPullRequestValue.java @@ -81,7 +81,7 @@ public String getLink() { @Override public String getAuthorLogin() { - return author.username; + return author.displayName; } @Override @@ -107,10 +107,6 @@ public void setAuthor(Author author) { this.author = author; } - public String getAuthorDisplayName() { - return author.displayName; - } - @Override @JsonInclude(JsonInclude.Include.NON_EMPTY) public List getReviewers() { @@ -155,27 +151,15 @@ public void setHref(String href) { public static class Author { @JsonProperty("account_id") private String identifier; - private String username; - @JsonProperty("display_name") + @JsonProperty("nickname") private String displayName; public Author() {} - public Author(String username) { - this.username = username; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } public String getIdentifier() { return identifier; } - public void setIndentifier(String identifier) { + public void setIdentifier(String identifier) { this.identifier = identifier; } diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint.java index d8d1dbd06..06f0bfc6b 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint.java @@ -85,6 +85,11 @@ public class BitbucketServerEndpoint extends AbstractBitbucketEndpoint { */ private boolean callCanMerge = true; + /** + * Whether to always call the can diff api when retrieving pull requests. + */ + private boolean callChanges = true; + /** * @param displayName Optional name to use to describe the end-point. * @param serverUrl The URL of this Bitbucket Server @@ -128,6 +133,15 @@ public void setCallCanMerge(boolean callCanMerge) { this.callCanMerge = callCanMerge; } + public boolean isCallChanges() { + return callChanges; + } + + @DataBoundSetter + public void setCallChanges(boolean callChanges) { + this.callChanges = callChanges; + } + /** * {@inheritDoc} */ diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java index cab41913c..1b7fc0b99 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/filesystem/BitbucketSCMFileSystem.java @@ -178,6 +178,7 @@ public SCMFileSystem build(@NonNull SCMSource source, @NonNull SCMHead head, @Ch } else if (pr.getCheckoutStrategy() == ChangeRequestCheckoutStrategy.HEAD) { ref = "pull-requests/" + pr.getId() + "/from"; } else if (pr.getCheckoutStrategy() == ChangeRequestCheckoutStrategy.MERGE) { + // No longer supported since bitbucket server v7, falls back to heavycheckout ref = "pull-requests/" + pr.getId() + "/merge"; } } else if (head instanceof BitbucketTagSCMHead) { diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/HookEventType.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/HookEventType.java index e6d9ab30a..59781548c 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/HookEventType.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/HookEventType.java @@ -111,6 +111,12 @@ public enum HookEventType { */ SERVER_PULL_REQUEST_REVIEWER_UPDATED("pr:reviewer:updated", NativeServerPullRequestHookProcessor.class), + /** + * @see Eventpayload-Sourcebranchupdated + * @since Bitbucket Server 7.0 + */ + SERVER_PULL_REQUEST_FROM_REF_UPDATED("pr:from_ref_updated", NativeServerPullRequestHookProcessor.class), + /** * Sent when hitting the {@literal "Test connection"} button in Bitbucket Server. Apparently undocumented. */ diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/NativeServerPullRequestHookProcessor.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/NativeServerPullRequestHookProcessor.java index 45a46c678..2f4a8682f 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/NativeServerPullRequestHookProcessor.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/NativeServerPullRequestHookProcessor.java @@ -82,6 +82,7 @@ public void process(HookEventType hookEvent, String payload, BitbucketType insta break; case SERVER_PULL_REQUEST_MODIFIED: case SERVER_PULL_REQUEST_REVIEWER_UPDATED: + case SERVER_PULL_REQUEST_FROM_REF_UPDATED: eventType = SCMEvent.Type.UPDATED; break; default: diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookConfiguration.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookConfiguration.java index 7ad1a2536..a1fcef4ca 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookConfiguration.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/WebhookConfiguration.java @@ -65,7 +65,8 @@ public class WebhookConfiguration { HookEventType.SERVER_PULL_REQUEST_DECLINED.getKey(), HookEventType.SERVER_PULL_REQUEST_DELETED.getKey(), HookEventType.SERVER_PULL_REQUEST_MODIFIED.getKey(), - HookEventType.SERVER_PULL_REQUEST_REVIEWER_UPDATED.getKey() + HookEventType.SERVER_PULL_REQUEST_REVIEWER_UPDATED.getKey(), + HookEventType.SERVER_PULL_REQUEST_FROM_REF_UPDATED.getKey() )); /** diff --git a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java index cc6e501ed..18b8a03d1 100644 --- a/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java +++ b/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/server/client/BitbucketServerAPIClient.java @@ -136,6 +136,7 @@ public class BitbucketServerAPIClient implements BitbucketApi { private static final String API_PULL_REQUESTS_PATH = API_REPOSITORY_PATH + "/pull-requests{?start,limit,at,direction,state}"; private static final String API_PULL_REQUEST_PATH = API_REPOSITORY_PATH + "/pull-requests/{id}"; private static final String API_PULL_REQUEST_MERGE_PATH = API_REPOSITORY_PATH + "/pull-requests/{id}/merge"; + private static final String API_PULL_REQUEST_CHANGES_PATH = API_REPOSITORY_PATH + "/pull-requests/{id}/changes{?start,limit}"; static final String API_BROWSE_PATH = API_REPOSITORY_PATH + "/browse{/path*}{?at}"; private static final String API_COMMITS_PATH = API_REPOSITORY_PATH + "/commits{/hash}"; private static final String API_PROJECT_PATH = API_BASE_PATH + "/projects/{owner}"; @@ -339,11 +340,21 @@ private List getPullRequests(UriTemplate template) } AbstractBitbucketEndpoint endpointConfig = BitbucketEndpointConfiguration.get().findEndpoint(baseURL); - if (endpointConfig instanceof BitbucketServerEndpoint && ((BitbucketServerEndpoint)endpointConfig).isCallCanMerge()) { + if (endpointConfig instanceof BitbucketServerEndpoint) { + final BitbucketServerEndpoint endpoint = (BitbucketServerEndpoint) endpointConfig; + if (!endpoint.isCallCanMerge() && !endpoint.isCallChanges()) { + return pullRequests; + } + // This is required for Bitbucket Server to update the refs/pull-requests/* references // See https://community.atlassian.com/t5/Bitbucket-questions/Change-pull-request-refs-after-Commit-instead-of-after-Approval/qaq-p/194702#M6829 for (BitbucketServerPullRequest pullRequest : pullRequests) { - pullRequest.setCanMerge(getPullRequestCanMergeById(Integer.parseInt(pullRequest.getId()))); + if (endpoint.isCallCanMerge()) { + pullRequest.setCanMerge(getPullRequestCanMergeById(pullRequest.getId())); + } + if (endpoint.isCallChanges()) { + callPullRequestChangesById(pullRequest.getId()); + } } } @@ -383,7 +394,17 @@ private void setupClosureForPRBranch(BitbucketServerPullRequest pr) { } } - private boolean getPullRequestCanMergeById(@NonNull Integer id) throws IOException { + private void callPullRequestChangesById(@NonNull String id) throws IOException { + String url = UriTemplate + .fromTemplate(API_PULL_REQUEST_CHANGES_PATH) + .set("owner", getUserCentricOwner()) + .set("repo", repositoryName) + .set("id", id).set("limit", 1) + .expand(); + getRequest(url); + } + + private boolean getPullRequestCanMergeById(@NonNull String id) throws IOException { String url = UriTemplate .fromTemplate(API_PULL_REQUEST_MERGE_PATH) .set("owner", getUserCentricOwner()) diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/config-detail.jelly b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/config-detail.jelly index 33bfb039a..c02283363 100644 --- a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/config-detail.jelly +++ b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/config-detail.jelly @@ -10,4 +10,7 @@ + + + diff --git a/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-callChanges.html b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-callChanges.html new file mode 100644 index 000000000..85610251c --- /dev/null +++ b/src/main/resources/com/cloudbees/jenkins/plugins/bitbucket/endpoints/BitbucketServerEndpoint/help-callChanges.html @@ -0,0 +1,3 @@ +
+ Always call the can changes api on pull requests to ensure the source code references are up to date (since BitBucket Server v7). +
diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketClientMockUtils.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketClientMockUtils.java index a48243e84..e371d3218 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketClientMockUtils.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/BitbucketClientMockUtils.java @@ -200,7 +200,7 @@ private static BitbucketPullRequestValue getPullRequest() { pr.setDestination(new BitbucketPullRequestValueDestination(repository, branch, commit)); pr.setId("23"); - pr.setAuthor(new BitbucketPullRequestValue.Author("amuniz")); + pr.setAuthor(new BitbucketPullRequestValue.Author()); pr.setLinks(new BitbucketPullRequestValue.Links("https://bitbucket.org/amuniz/test-repos/pull-requests/23")); return pr; } diff --git a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest.java b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest.java index 9a3c4c31d..9b3213dec 100644 --- a/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest.java +++ b/src/test/java/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest.java @@ -69,7 +69,8 @@ public void createPayloadOrigin() throws Exception { assertThat(event.getPullRequest(), notNullValue()); assertThat(event.getPullRequest().getTitle(), is("README.md edited online with Bitbucket")); - assertThat(event.getPullRequest().getAuthorLogin(), is("stephenc")); + assertThat(event.getPullRequest().getAuthorIdentifier(), is("123456:dead-beef")); + assertThat(event.getPullRequest().getAuthorLogin(), is("Stephen Connolly")); assertThat(event.getPullRequest().getLink(), is("https://bitbucket.org/cloudbeers/temp/pull-requests/1")); @@ -134,7 +135,8 @@ public void createPayloadFork() throws Exception { assertThat(event.getPullRequest(), notNullValue()); assertThat(event.getPullRequest().getTitle(), is("Forking for PR")); - assertThat(event.getPullRequest().getAuthorLogin(), is("stephenc")); + assertThat(event.getPullRequest().getAuthorIdentifier(), is("123456:dead-beef")); + assertThat(event.getPullRequest().getAuthorLogin(), is("Stephen Connolly")); assertThat(event.getPullRequest().getLink(), is("https://bitbucket.org/cloudbeers/temp/pull-requests/3")); @@ -198,7 +200,8 @@ public void updatePayload_newCommit() throws Exception { assertThat(event.getPullRequest(), notNullValue()); assertThat(event.getPullRequest().getTitle(), is("Forking for PR")); - assertThat(event.getPullRequest().getAuthorLogin(), is("stephenc")); + assertThat(event.getPullRequest().getAuthorIdentifier(), is("123456:dead-beef")); + assertThat(event.getPullRequest().getAuthorLogin(), is("Stephen Connolly")); assertThat(event.getPullRequest().getLink(), is("https://bitbucket.org/cloudbeers/temp/pull-requests/3")); @@ -262,7 +265,8 @@ public void updatePayload_newDestination() throws Exception { assertThat(event.getPullRequest(), notNullValue()); assertThat(event.getPullRequest().getTitle(), is("Forking for PR")); - assertThat(event.getPullRequest().getAuthorLogin(), is("stephenc")); + assertThat(event.getPullRequest().getAuthorIdentifier(), is("123456:dead-beef")); + assertThat(event.getPullRequest().getAuthorLogin(), is("Stephen Connolly")); assertThat(event.getPullRequest().getLink(), is("https://bitbucket.org/cloudbeers/temp/pull-requests/3")); @@ -326,7 +330,8 @@ public void updatePayload_newDestinationCommit() throws Exception { assertThat(event.getPullRequest(), notNullValue()); assertThat(event.getPullRequest().getTitle(), is("Forking for PR")); - assertThat(event.getPullRequest().getAuthorLogin(), is("stephenc")); + assertThat(event.getPullRequest().getAuthorIdentifier(), is("123456:dead-beef")); + assertThat(event.getPullRequest().getAuthorLogin(), is("Stephen Connolly")); assertThat(event.getPullRequest().getLink(), is("https://bitbucket.org/cloudbeers/temp/pull-requests/3")); @@ -390,7 +395,8 @@ public void rejectedPayload() throws Exception { assertThat(event.getPullRequest(), notNullValue()); assertThat(event.getPullRequest().getTitle(), is("Forking for PR")); - assertThat(event.getPullRequest().getAuthorLogin(), is("stephenc")); + assertThat(event.getPullRequest().getAuthorIdentifier(), is("123456:dead-beef")); + assertThat(event.getPullRequest().getAuthorLogin(), is("Stephen Connolly")); assertThat(event.getPullRequest().getLink(), is("https://bitbucket.org/cloudbeers/temp/pull-requests/3")); @@ -455,7 +461,8 @@ public void fulfilledPayload() throws Exception { assertThat(event.getPullRequest(), notNullValue()); assertThat(event.getPullRequest().getTitle(), is("README.md edited online with Bitbucket")); - assertThat(event.getPullRequest().getAuthorLogin(), is("stephenc")); + assertThat(event.getPullRequest().getAuthorIdentifier(), is("123456:dead-beef")); + assertThat(event.getPullRequest().getAuthorLogin(), is("Stephen Connolly")); assertThat(event.getPullRequest().getLink(), is("https://bitbucket.org/cloudbeers/temp/pull-requests/2")); diff --git a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/createPayloadFork.json b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/createPayloadFork.json index c8a7add41..bf7728ea5 100644 --- a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/createPayloadFork.json +++ b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/createPayloadFork.json @@ -106,8 +106,9 @@ "reason": "", "updated_on": "2017-03-06T11:52:20.120024+00:00", "author": { - "username": "stephenc", - "display_name": "Stephen Connolly", + "account_id": "123456:dead-beef", + "nickname": "Stephen Connolly", + "display_name": "Stephen Q. Connolly", "type": "user", "uuid": "{f70f195e-ade1-4961-9f89-547541377b80}", "links": { diff --git a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/createPayloadOrigin.json b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/createPayloadOrigin.json index 16ff31413..7a37ff0eb 100644 --- a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/createPayloadOrigin.json +++ b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/createPayloadOrigin.json @@ -35,8 +35,9 @@ } }, "author": { - "username": "stephenc", - "display_name": "Stephen Connolly", + "account_id": "123456:dead-beef", + "nickname": "Stephen Connolly", + "display_name": "Stephen Q. Connolly", "type": "user", "uuid": "{f70f195e-ade1-4961-9f89-547541377b80}", "links": { diff --git a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/fulfilledPayload.json b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/fulfilledPayload.json index acedd12f2..a07f921bf 100644 --- a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/fulfilledPayload.json +++ b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/fulfilledPayload.json @@ -129,8 +129,9 @@ "reason": "", "updated_on": "2017-03-06T10:41:59.551194+00:00", "author": { - "username": "stephenc", - "display_name": "Stephen Connolly", + "account_id": "123456:dead-beef", + "nickname": "Stephen Connolly", + "display_name": "Stephen Q. Connolly", "type": "user", "uuid": "{f70f195e-ade1-4961-9f89-547541377b80}", "links": { diff --git a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/rejectedPayload.json b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/rejectedPayload.json index b39962ca9..55f07e6ab 100644 --- a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/rejectedPayload.json +++ b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/rejectedPayload.json @@ -122,8 +122,9 @@ "reason": "", "updated_on": "2017-03-06T12:05:11.484201+00:00", "author": { - "username": "stephenc", - "display_name": "Stephen Connolly", + "account_id": "123456:dead-beef", + "nickname": "Stephen Connolly", + "display_name": "Stephen Q. Connolly", "type": "user", "uuid": "{f70f195e-ade1-4961-9f89-547541377b80}", "links": { diff --git a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newCommit.json b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newCommit.json index bdc47125c..3cd26cd85 100644 --- a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newCommit.json +++ b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newCommit.json @@ -35,8 +35,9 @@ } }, "author": { - "username": "stephenc", - "display_name": "Stephen Connolly", + "account_id": "123456:dead-beef", + "nickname": "Stephen Connolly", + "display_name": "Stephen Q. Connolly", "type": "user", "uuid": "{f70f195e-ade1-4961-9f89-547541377b80}", "links": { diff --git a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newDestination.json b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newDestination.json index 35ccaff35..4efe17223 100644 --- a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newDestination.json +++ b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newDestination.json @@ -106,8 +106,9 @@ "reason": "", "updated_on": "2017-03-06T11:59:39.916949+00:00", "author": { - "username": "stephenc", - "display_name": "Stephen Connolly", + "account_id": "123456:dead-beef", + "nickname": "Stephen Connolly", + "display_name": "Stephen Q. Connolly", "type": "user", "uuid": "{f70f195e-ade1-4961-9f89-547541377b80}", "links": { diff --git a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newDestinationCommit.json b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newDestinationCommit.json index de4258491..73b8041cd 100644 --- a/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newDestinationCommit.json +++ b/src/test/resources/com/cloudbees/jenkins/plugins/bitbucket/client/events/BitbucketCloudPullRequestEventTest/updatePayload_newDestinationCommit.json @@ -106,8 +106,9 @@ "reason": "", "updated_on": "2017-03-06T12:02:59.640844+00:00", "author": { - "username": "stephenc", - "display_name": "Stephen Connolly", + "account_id": "123456:dead-beef", + "nickname": "Stephen Connolly", + "display_name": "Stephen Q. Connolly", "type": "user", "uuid": "{f70f195e-ade1-4961-9f89-547541377b80}", "links": {