[JENKINS-39355 Follow-up] Unpicking some of the replicated hacks from…#23
[JENKINS-39355 Follow-up] Unpicking some of the replicated hacks from…#23amuniz merged 18 commits intojenkinsci:masterfrom
Conversation
… the GitHub Org Folders plugin
- Also add bitbucket links and icons
|
Do you plan to continue working on this? I'd like to review and merge #25 but it will generate non-trivial conflicts (specially as you are changing the representations of |
|
Still working on this |
|
@amuniz ready for review now |
|
I have tested this against BitBucket and BitBucket Enterprise. |
pom.xml
Outdated
| <groupId>org.jenkins-ci.plugins</groupId> | ||
| <artifactId>git</artifactId> | ||
| <version>2.3.5</version> | ||
| <version>2.6.1-SNAPSHOT</version> |
There was a problem hiding this comment.
Is this waiting for a specific PR? If so, mention it here in a comment.
| </dependency> | ||
| <dependency> | ||
| <groupId>org.jenkins-ci.plugins</groupId> | ||
| <artifactId>branch-api</artifactId> |
pom.xml
Outdated
| <groupId>org.jenkins-ci.plugins</groupId> | ||
| <artifactId>branch-api</artifactId> | ||
| <version>1.10.2</version> | ||
| <version>2.0.1-SNAPSHOT</version> |
| /** | ||
| * Invisible property that retains information about GitHub repository. | ||
| * | ||
| * @author Kohsuke Kawaguchi |
There was a problem hiding this comment.
Really? I think this is a ship of Theseus.
| + pull.getSource().getBranch().getName()); | ||
| } else { | ||
| e.printStackTrace( | ||
| listener.error("Can not resolve hash: [%s]%n", pull.getSource().getCommit().getHash())); |
| return Integer.parseInt(metadata.getId()); | ||
| } else { | ||
| return null; | ||
| return new PullRequestSCMHead(repoOwner, repoName, super.getName(), new BitbucketPullRequest() { |
There was a problem hiding this comment.
Do not use an anonymous inner class here; it will not serialize well.
There was a problem hiding this comment.
It is not stored, only data extracted from it, but i'all double check
|
2 test failures, related? Not clear to me after all this refactoring. |
|
Possibly tests need updating |
pom.xml
Outdated
| <groupId>org.jenkins-ci.plugins</groupId> | ||
| <artifactId>mercurial</artifactId> | ||
| <version>1.54</version> | ||
| <version>1.58-SNAPSHOT</version> |
|
Currently failing until a snapshot of mercurial plugin is deployed |
b40537c to
80adc94
Compare
amuniz
left a comment
There was a problem hiding this comment.
After a more or less blind review (as I didn't check what changed upstream in scm-api and branch-api), it looks ok to me, but I want to try it working before approving.
| === Notes | ||
|
|
||
| * Unlike GitHub, in BitBucket, https://bitbucket.org/site/master/issues/4828/team-admins-dont-have-read-access-to-forks[team admins do not have access to forks]. | ||
| This means that when you have a private repository, or a private fork of a public repository, the team admin will not be able to see the PRs within the fork. |
There was a problem hiding this comment.
In general the user configured for scanning needs to have read permission in all repositories intended to be scanned.
There was a problem hiding this comment.
Including the forks where a PR to be scanned lives.
| StandardUsernameCredentials.class, context, ACL.SYSTEM, bitbucketDomainRequirements())); | ||
| public StandardListBoxModel fillCredentials(StandardListBoxModel result, SCMSourceOwner context) { | ||
| result.includeMatchingAs( | ||
| context instanceof Queue.Task |
There was a problem hiding this comment.
Is SCMSourceOwner a Queue.Task under some condition?
There was a problem hiding this comment.
All current implementations of SCMSourceOwner are a Queue.Task but there is not requirement that they be so
| import jenkins.scm.api.metadata.AvatarMetadataAction; | ||
|
|
||
| /** | ||
| * Invisible property that retains information about GitHub repository. |
| } | ||
|
|
||
| @Extension | ||
| private String bitbucketServerUrl() { |
There was a problem hiding this comment.
This method name is misleading as it can return the Bitbucket Cloud or Bitbucket Server URL. I think bitbucketUrl would be preferable.
There was a problem hiding this comment.
This should be fixed before merge.
| @Override | ||
| public List<Action> retrieveActions(@NonNull SCMNavigatorOwner owner, | ||
| @CheckForNull SCMNavigatorEvent event, | ||
| @NonNull TaskListener listener) |
| if (bitbucket.isPrivate()) { | ||
| List<? extends BitbucketPullRequest> pulls = bitbucket.getPullRequests(); | ||
| for (final BitbucketPullRequest pull : pulls) { | ||
| checkInterrupt(); |
There was a problem hiding this comment.
Why is this explicit check needed? Is this running in a different thread from the main scan thread?
There was a problem hiding this comment.
You are supposed to call this method periodically so that people can abort scanning / indexing
|
|
||
| /** | ||
| * {@link SCMHead} for a BitBucket branch. | ||
| * @since FIXME |
There was a problem hiding this comment.
tradition is to replace the FIXMEs after merge
| import org.codehaus.jackson.annotate.JsonProperty; | ||
|
|
||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public class BitbucketPullRequestValueDestination implements BitbucketPullRequestDestination { |
There was a problem hiding this comment.
Isn't BitbucketPullRequestValueRepository reusable for this purpose?
| branch = new BitbucketCloudBranch(); | ||
| branch.setName("branch1"); | ||
| destination.setBranch(branch); | ||
| pr.setDestination(destination); |
There was a problem hiding this comment.
Missing call to destination.setRepository(...) - probably not used now in tests, but expected to be set anyway.
| this.listener = listener; | ||
| } | ||
|
|
||
| @NonNull |
There was a problem hiding this comment.
@NonNull and then return null, something is wrong here (maybe not affecting to tests as a lot of code is mocked)
| result.add(new BitbucketRepoMetadataAction(r)); | ||
| } | ||
| String serverUrl = StringUtils.removeEnd(bitbucketServerUrl(), "/"); | ||
| result.add(new BitbucketLink("icon-bitbucket-repo", serverUrl + "/" + repoOwner + "/" + repository)); |
There was a problem hiding this comment.
The link pattern doesn't work with Bitbucket Server,
Here is a suggestion:
String serverUrl = StringUtils.removeEnd(bitbucketServerUrl(), "/");
if (StringUtils.isNotEmpty(bitbucketServerUrl)) {
result.add(new BitbucketLink("icon-bitbucket-repo", serverUrl + "/projects/" + repoOwner + "/repos/" + repository));
}else{
result.add(new BitbucketLink("icon-bitbucket-repo", serverUrl + "/" + repoOwner + "/" + repository));
}
| PullRequestSCMHead pr = (PullRequestSCMHead) head; | ||
| branchUrl = pr.getRepoOwner() + "/" + pr.getRepository() + "/branch/" + pr.getBranchName(); | ||
| } else { | ||
| branchUrl = repoOwner + "/" + repository + "/branch/" + head.getName(); |
There was a problem hiding this comment.
Link generated doesn't work for Bitbucket Server.
Now the question is, should it link to the «compare» or «source»/«browse» screen?
And in the case of a PullRequest, link back to the PullRequest or same «branch» link?
There was a problem hiding this comment.
In the case of the pull request, linking to the pull request itself would make sense.
In the spots where Jenkins displays the COMMIT ID, such as the Changes page of a given job, I think linking to the specific Commit would be lovely.
https://bitbucket.mycorp.com/projects/my-prj/repos/my-repo/commits/my-commit-id
amuniz
left a comment
There was a problem hiding this comment.
No major changes required but at least this two little details should be fixed.
| @@ -1,5 +1,13 @@ | |||
| BitbucketLink.DisplayName=Bitbucket | |||
| BitbucketSCMNavigator.UncategorizedSCMSourceCategory.DisplayName=Repositories | |||
| BitbucketSCMSource.UncategorizedSCMHeadCategory.DisplayName=Repositories | |||
There was a problem hiding this comment.
I think this should be Branches, right?
There was a problem hiding this comment.
Yeah, either this or the previous line is wrong, checked in the UI.
| } | ||
|
|
||
| @Extension | ||
| private String bitbucketServerUrl() { |
There was a problem hiding this comment.
This should be fixed before merge.
|
@amuniz should be addressed |
|
👍 Only pending a release of |
|
This pull request originates from a CloudBees employee. At CloudBees, we require that all pull requests be reviewed by other CloudBees employees before we seek to have the change accepted. If you want to learn more about our process please see this explanation. |
… the GitHub Org Folders plugin
@amuniz @reviewbybees