Skip to content

[JENKINS-39355 Follow-up] Unpicking some of the replicated hacks from…#23

Merged
amuniz merged 18 commits intojenkinsci:masterfrom
stephenc:jenkins-39355-follow-up
Jan 16, 2017
Merged

[JENKINS-39355 Follow-up] Unpicking some of the replicated hacks from…#23
amuniz merged 18 commits intojenkinsci:masterfrom
stephenc:jenkins-39355-follow-up

Conversation

@stephenc
Copy link
Member

@stephenc stephenc commented Oct 28, 2016

… the GitHub Org Folders plugin

@amuniz @reviewbybees

@amuniz
Copy link
Member

amuniz commented Nov 23, 2016

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 SCMHead here).

@amuniz amuniz mentioned this pull request Nov 23, 2016
6 tasks
@stephenc
Copy link
Member Author

Still working on this

@stephenc
Copy link
Member Author

@amuniz ready for review now

@stephenc
Copy link
Member Author

I have tested this against BitBucket and BitBucket Enterprise.

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible readResolve mistake.

pom.xml Outdated
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>git</artifactId>
<version>2.3.5</version>
<version>2.6.1-SNAPSHOT</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this waiting for a specific PR? If so, mention it here in a comment.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

downstream of jenkinsci/git-plugin#454

</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>branch-api</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pom.xml Outdated
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>branch-api</artifactId>
<version>1.10.2</version>
<version>2.0.1-SNAPSHOT</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Member Author

@stephenc stephenc Dec 15, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
* Invisible property that retains information about GitHub repository.
*
* @author Kohsuke Kawaguchi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot

return Integer.parseInt(metadata.getId());
} else {
return null;
return new PullRequestSCMHead(repoOwner, repoName, super.getName(), new BitbucketPullRequest() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not use an anonymous inner class here; it will not serialize well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not stored, only data extracted from it, but i'all double check

@amuniz
Copy link
Member

amuniz commented Dec 15, 2016

2 test failures, related? Not clear to me after all this refactoring.

@stephenc
Copy link
Member Author

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>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephenc
Copy link
Member Author

Currently failing until a snapshot of mercurial plugin is deployed

@stephenc stephenc force-pushed the jenkins-39355-follow-up branch from b40537c to 80adc94 Compare December 16, 2016 13:45
Copy link
Member

@amuniz amuniz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general the user configured for scanning needs to have read permission in all repositories intended to be scanned.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is SCMSourceOwner a Queue.Task under some condition?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub -> Bitbucket

}

@Extension
private String bitbucketServerUrl() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method name is misleading as it can return the Bitbucket Cloud or Bitbucket Server URL. I think bitbucketUrl would be preferable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed before merge.

@Override
public List<Action> retrieveActions(@NonNull SCMNavigatorOwner owner,
@CheckForNull SCMNavigatorEvent event,
@NonNull TaskListener listener)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird indentation

if (bitbucket.isPrivate()) {
List<? extends BitbucketPullRequest> pulls = bitbucket.getPullRequests();
for (final BitbucketPullRequest pull : pulls) {
checkInterrupt();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this explicit check needed? Is this running in a different thread from the main scan thread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are supposed to call this method periodically so that people can abort scanning / indexing


/**
* {@link SCMHead} for a BitBucket branch.
* @since FIXME
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.0.0-beta-1?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tradition is to replace the FIXMEs after merge

import org.codehaus.jackson.annotate.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
public class BitbucketPullRequestValueDestination implements BitbucketPullRequestDestination {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't BitbucketPullRequestValueRepository reusable for this purpose?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No

branch = new BitbucketCloudBranch();
branch.setName("branch1");
destination.setBranch(branch);
pr.setDestination(destination);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing call to destination.setRepository(...) - probably not used now in tests, but expected to be set anyway.

this.listener = listener;
}

@NonNull
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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));
        }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stephenc what about this?

PullRequestSCMHead pr = (PullRequestSCMHead) head;
branchUrl = pr.getRepoOwner() + "/" + pr.getRepository() + "/branch/" + pr.getBranchName();
} else {
branchUrl = repoOwner + "/" + repository + "/branch/" + head.getName();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

@amuniz amuniz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be Branches, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, either this or the previous line is wrong, checked in the UI.

}

@Extension
private String bitbucketServerUrl() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed before merge.

@stephenc
Copy link
Member Author

@amuniz should be addressed

@amuniz
Copy link
Member

amuniz commented Jan 13, 2017

👍 Only pending a release of mercurial-plugin, holding merge until that.

@tknerr
Copy link

tknerr commented Jan 13, 2017

@stephenc @amuniz very cool stuff!

btw: does that mean we with this PR we get backlinks to the pull request / commit as well (e.g. when the changes are displayed in jenkins)?

@ghost
Copy link

ghost commented Jan 13, 2017

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.

@amuniz amuniz merged commit 5c1b33f into jenkinsci:master Jan 16, 2017
@stephenc stephenc deleted the jenkins-39355-follow-up branch January 16, 2017 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants