@DataBoundConstructor public Endpoint(String apiUri, String name) { this.apiUri = GitHubConfiguration.normalizeApiUri(Util.fixEmptyAndTrim(apiUri)); if (StringUtils.isBlank(name)) { this.name = SCMName.fromUrl(this.apiUri, COMMON_PREFIX_HOSTNAMES); } else { this.name = name.trim(); } }
/** * Gets the formatted display name (which will always include the api url) * * @return the formatted display name. * @since 1.28.0 */ public String getDisplayName() { String gitHubName = getName(); boolean isGitHubCom = StringUtils.isBlank(apiUrl) || GITHUB_URL.equals(apiUrl); if (StringUtils.isBlank(gitHubName)) { gitHubName = isGitHubCom ? PUBLIC_GITHUB_NAME : SCMName.fromUrl(apiUrl, COMMON_PREFIX_HOSTNAMES); } String gitHubUrl = isGitHubCom ? "https://github.com" : StringUtils.removeEnd(apiUrl, "/api/v3"); return StringUtils.isBlank(gitHubName) ? gitHubUrl : Messages.GitHubServerConfig_displayName(gitHubName, gitHubUrl); }
/** * Constructor * * @param displayName Optional name to use to describe the end-point. * @param serverUrl The URL of this Gitea Server * @param manageHooks {@code true} if and only if Jenkins is supposed to auto-manage hooks for this end-point. * @param credentialsId The {@link StandardUsernamePasswordCredentials#getId()} of the credentials to use for * auto-management of hooks. * @param aliasUrl The URL this Gitea Server thinks it is at. * @since 1.0.5 */ @DataBoundConstructor public GiteaServer(@CheckForNull String displayName, @NonNull String serverUrl, boolean manageHooks, @CheckForNull String credentialsId, @CheckForNull String aliasUrl) { this.manageHooks = manageHooks && StringUtils.isNotBlank(credentialsId); this.credentialsId = manageHooks ? credentialsId : null; this.serverUrl = GiteaServers.normalizeServerUrl(serverUrl); this.displayName = StringUtils.isBlank(displayName) ? SCMName.fromUrl(this.serverUrl, COMMON_PREFIX_HOSTNAMES) : displayName; this.aliasUrl = StringUtils.trimToNull(GiteaServers.normalizeServerUrl(aliasUrl)); }