jenkins.scm.api.SCMNavigatorEvent Java Examples

The following examples show how to use jenkins.scm.api.SCMNavigatorEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GitLabSCMNavigator.java    From gitlab-branch-source-plugin with MIT License 5 votes vote down vote up
@NonNull
@Override
protected List<Action> retrieveActions(@NonNull SCMNavigatorOwner owner,
    SCMNavigatorEvent event,
    @NonNull TaskListener listener) throws IOException, InterruptedException {
    getGitlabOwner();
    String fullName = gitlabOwner.getFullName();
    String webUrl = gitlabOwner.getWebUrl();
    String avatarUrl = gitlabOwner.getAvatarUrl();
    String description = null;
    if (gitlabOwner instanceof GitLabGroup) {
        description = ((GitLabGroup) gitlabOwner).getDescription();
    }
    List<Action> result = new ArrayList<>();
    result.add(new ObjectMetadataAction(
        Util.fixEmpty(fullName),
        description,
        webUrl)
    );
    if (StringUtils.isNotBlank(avatarUrl)) {
        result.add(new GitLabAvatar(avatarUrl));
    }
    result.add(GitLabLink.toGroup(webUrl));
    if (StringUtils.isBlank(webUrl)) {
        listener.getLogger().println("Web URL unspecified");
    } else {
        listener.getLogger().printf("%s URL: %s%n", gitlabOwner.getWord(),
            HyperlinkNote
                .encodeTo(webUrl, StringUtils.defaultIfBlank(fullName, webUrl)));
    }
    return result;
}
 
Example #2
Source File: GiteaSCMNavigator.java    From gitea-plugin with MIT License 5 votes vote down vote up
@NonNull
@Override
protected List<Action> retrieveActions(@NonNull SCMNavigatorOwner owner, SCMNavigatorEvent event,
                                       @NonNull TaskListener listener) throws IOException, InterruptedException {
    if (this.giteaOwner == null) {
        try (GiteaConnection c = gitea(owner).open()) {
            this.giteaOwner = c.fetchUser(repoOwner);
            if (StringUtils.isBlank(giteaOwner.getEmail())) {
                this.giteaOwner = c.fetchOrganization(repoOwner);
            }
        }
    }
    List<Action> result = new ArrayList<>();
    String objectUrl = UriTemplate.buildFromTemplate(serverUrl)
            .path("owner")
            .build()
            .set("owner", repoOwner)
            .expand();
    result.add(new ObjectMetadataAction(
            Util.fixEmpty(giteaOwner.getFullName()),
            null,
            objectUrl)
    );
    if (StringUtils.isNotBlank(giteaOwner.getAvatarUrl())) {
        result.add(new GiteaAvatar(giteaOwner.getAvatarUrl()));
    }
    result.add(new GiteaLink("icon-gitea-org", objectUrl));
    if (giteaOwner instanceof GiteaOrganization) {
        String website = ((GiteaOrganization) giteaOwner).getWebsite();
        if (StringUtils.isBlank(website)) {
            listener.getLogger().println("Organization website: unspecified");
        } else {
            listener.getLogger().printf("Organization website: %s%n",
                    HyperlinkNote.encodeTo(website, StringUtils.defaultIfBlank(giteaOwner.getFullName(), website)));
        }
    }
    return result;
}
 
Example #3
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@NonNull
@Override
public List<Action> retrieveActions(@NonNull SCMNavigatorOwner owner,
                                    @CheckForNull SCMNavigatorEvent event,
                                    @NonNull TaskListener listener) throws IOException, InterruptedException {
    // TODO when we have support for trusted events, use the details from event if event was from trusted source
    listener.getLogger().printf("Looking up details of %s...%n", getRepoOwner());
    List<Action> result = new ArrayList<>();
    StandardCredentials credentials = Connector.lookupScanCredentials((Item)owner, getApiUri(), credentialsId);
    GitHub hub = Connector.connect(getApiUri(), credentials);
    try {
        Connector.checkApiRateLimit(listener, hub);
        GHUser u = hub.getUser(getRepoOwner());
        String objectUrl = u.getHtmlUrl() == null ? null : u.getHtmlUrl().toExternalForm();
        result.add(new ObjectMetadataAction(
                Util.fixEmpty(u.getName()),
                null,
                objectUrl)
        );
        result.add(new GitHubOrgMetadataAction(u));
        result.add(new GitHubLink("icon-github-logo", u.getHtmlUrl()));
        if (objectUrl == null) {
            listener.getLogger().println("Organization URL: unspecified");
        } else {
            listener.getLogger().printf("Organization URL: %s%n",
                    HyperlinkNote.encodeTo(objectUrl, StringUtils.defaultIfBlank(u.getName(), objectUrl)));
        }
        return result;
    } finally {
        Connector.release(hub);
    }
}
 
Example #4
Source File: GitLabSCMNavigator.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 4 votes vote down vote up
@Nonnull
@Override
protected List<Action> retrieveActions(@Nonnull SCMNavigatorOwner owner, @CheckForNull SCMNavigatorEvent event, @Nonnull TaskListener listener) throws IOException, InterruptedException {
    return Collections.<Action>singletonList(GitLabLinkAction.create(getPronoun(), ICON_GITLAB, gitLabConnection(getSourceSettings().getConnectionName()).getUrl()));
}