private PrnfsSettings getSettings() throws Exception { final PrnfsSettings settings = securityService .withPermission(ADMIN, "Getting config") .call( new Operation<PrnfsSettings, Exception>() { @Override public PrnfsSettings perform() throws Exception { return getPrnfsSettings(pluginSettingsFactory.createGlobalSettings()); } }); return settings; }
/** * Get the url for notifying of Jenkins. Protected for testing purposes * * @param repository The repository to base the request to. * @param jenkinsBase The base URL of the Jenkins instance * @param cloneType The type used to clone the repository * @param customCloneUrl The url used for cloning the repository * @param strRef The branch ref related to the commit * @param strSha1 The commit's SHA1 hash code. * @param omitHashCode Defines whether the commit's SHA1 hash code is omitted in notification to * Jenkins. * @return The url to use for notifying Jenkins */ protected String getUrl( final Repository repository, final String jenkinsBase, final String cloneType, final String customCloneUrl, final String strRef, final String strSha1, boolean omitHashCode, boolean omitBranchName) { String cloneUrl = customCloneUrl; // Older installs won't have a cloneType value - treat as custom if (cloneType != null && !cloneType.equals("custom")) { if (cloneType.equals("http")) { cloneUrl = navBuilder.repo(repository).clone("git").buildAbsoluteWithoutUsername(); } else if (cloneType.equals("ssh")) { // The user just pushed to the repo, so must have had access cloneUrl = securityService.doWithPermission( "Retrieving SSH clone url", Permission.REPO_READ, new UncheckedOperation<String>() { @Override public String perform() { return sshCloneUrlResolver.getCloneUrl(repository); } }); } else { LOGGER.error("Unknown cloneType: {}", cloneType); throw new RuntimeException("Unknown cloneType: " + cloneType); } } StringBuilder url = new StringBuilder(); url.append(String.format(BASE_URL, jenkinsBase, urlEncode(cloneUrl))); if (strRef != null && !omitBranchName) url.append(String.format(BRANCH_URL_PARAMETER, urlEncode(strRef))); if (!omitHashCode) url.append(String.format(HASH_URL_PARAMETER, strSha1)); return url.toString(); }