Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add func to list github orgs #187

Merged
merged 2 commits into from
Jan 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,39 @@ public boolean isApiUriSelectable() {
return !GitHubConfiguration.get().getEndpoints().isEmpty();
}


@RequirePOST
public ListBoxModel doFillOrganizationItems(@CheckForNull @AncestorInPath Item context, @QueryParameter String apiUri,
@QueryParameter String credentialsId) throws IOException {
if (credentialsId == null) {
return new ListBoxModel();
}
if (context == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) ||
context != null && !context.hasPermission(Item.EXTENDED_READ)) {
return new ListBoxModel(); // not supposed to be seeing this form
}
if (context != null && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
return new ListBoxModel(); // not permitted to try connecting with these credentials
}
try {
StandardCredentials credentials = Connector.lookupScanCredentials(context, apiUri, credentialsId);
GitHub github = Connector.connect(apiUri, credentials);
if (!github.isAnonymous()) {
ListBoxModel model = new ListBoxModel();
for (Map.Entry<String,GHOrganization> entry : github.getMyOrganizations().entrySet()) {
model.add(entry.getKey(), entry.getValue().getAvatarUrl());
}
return model;
}
}
catch (FillErrorResponse e) {
throw e;
} catch (Throwable e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new FillErrorResponse(e.getMessage(), false);
}
throw new FillErrorResponse(Messages.GitHubSCMSource_CouldNotConnectionGithub(credentialsId),true);
}
@RequirePOST
public ListBoxModel doFillRepositoryItems(@CheckForNull @AncestorInPath Item context, @QueryParameter String apiUri,
@QueryParameter String credentialsId, @QueryParameter String repoOwner) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ GitHubSCMSource.Pronoun=Repository
GitHubSCMSource.UncategorizedCategory=Branches
GitHubSCMSource.did_you_mean_to_use_to_match_all_branches=Did you mean to use * to match all branches?
GitHubSCMSource.NoMatchingOwner=Could not find owner: {0}
GitHubSCMSource.CouldNotConnectionGithub=Could not connect github with credential: {0}

OriginPullRequestDiscoveryTrait.authorityDisplayName=Trust origin pull requests
PullRequestSCMHead.Pronoun=Pull Request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ GitHubSCMNavigator.UncategorizedCategory=\u4ED3\u5E93
GitHubSCMSource.ChangeRequestCategory=Pull Request
GitHubSCMSource.TagCategory=\u6807\u7B7E
GitHubSCMSource.DisplayName=GitHub


GitHubSCMSource.CouldNotConnectionGithub=\u65e0\u6cd5\u4f7f\u7528\u51ed\u8bc1\u8fde\u63a5\u5230\u0067\u0069\u0074\u0068\u0075\u0062: {0}
GitHubSCMSource.Pronoun=\u4ED3\u5E93
GitHubSCMSource.UncategorizedCategory=\u5206\u652F
GitHubSCMSource.did_you_mean_to_use_to_match_all_branches=\u4F60\u7684\u610F\u601D\u662F\u8981\u4F7F\u7528 * \u5339\u914D\u6240\u6709\u7684\u5206\u652F\u5417\uFF1F
GitHubSCMSource.NoMatchingOwner=\u65E0\u6CD5\u627E\u5230\u62E5\u6709\u8005\uFF1A {0}


OriginPullRequestDiscoveryTrait.authorityDisplayName=\u4FE1\u4EFB origin \u7684 Pull Request
PullRequestSCMHead.Pronoun=Pull Request
BranchDiscoveryTrait.excludePRs=\u4E0D\u5305\u62EC\u4F5C\u4E3A PRs \u7684\u5206\u652F
Expand Down