/** * Creates an empty builder. * * @return a new empty builder. */ @NonNull public static GitURIRequirementsBuilder create() { return new GitURIRequirementsBuilder(Collections.<DomainRequirement>emptyList()); }
Matcher matcher = SINGLE_SLASH_FILE_URI.matcher(uri); if (matcher.matches()) { return withScheme("file").withPath(matcher.group(2)).withoutHostname().withoutHostnamePort(); withScheme(matcher.group(1)); if (!"file".equals(matcher.group(1)) && matcher.group(4) != null) { withPath(matcher.group(7)); if (matcher.group(5) != null) { withHostnamePort(matcher.group(4), Integer.parseInt(matcher.group(5))); } else { withHostname(matcher.group(4)).withoutHostnamePort(); withPath(matcher.group(4)+"/"+matcher.group(7)); return withScheme("ssh").withPath(matcher.group(4)).withHostnamePort(matcher.group(3),22); return withScheme("ssh").withPath(matcher.group(4)).withHostnamePort(matcher.group(3),22); return withScheme("file").withPath(matcher.group(2)).withoutHostname().withoutHostnamePort(); return withoutScheme().withoutPath().withoutHostname().withoutHostnamePort();
private static StandardCredentials lookupCredentials(@CheckForNull Item project, String credentialId, String uri) { return (credentialId == null) ? null : CredentialsMatchers.firstOrNull( CredentialsProvider.lookupCredentials(StandardCredentials.class, project, ACL.SYSTEM, GitURIRequirementsBuilder.fromUri(uri).build()), CredentialsMatchers.withId(credentialId)); }
/** * Replace any hostname or hostname:port requirements with the supplied hostname and port. * * @param hostname the hostname to use as a requirement or (@code null} to not add any requirement * @param port the port or {@code -1} to not add {@link com.cloudbees.plugins.credentials.domains.HostnamePortRequirement}s * @return {@code this}. */ @NonNull public GitURIRequirementsBuilder withHostnamePort(@CheckForNull String hostname, int port) { withoutHostname(); withoutHostnamePort(); if (hostname != null) { requirements.add(new HostnameRequirement(hostname)); if (port != -1) { requirements.add(new HostnamePortRequirement(hostname, port)); } } return this; }
/** * Replace any hostname requirements with the supplied hostname. * * @param hostname the hostname to use as a requirement * @return {@code this}. */ @NonNull public GitURIRequirementsBuilder withHostname(@CheckForNull String hostname) { return withHostnamePort(hostname, -1); }
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item project, @QueryParameter String url, @QueryParameter String credentialsId) { if (project == null && !Jenkins.getActiveInstance().hasPermission(Jenkins.ADMINISTER) || project != null && !project.hasPermission(Item.EXTENDED_READ)) { return new StandardListBoxModel().includeCurrentValue(credentialsId); } if (project == null) { /* Construct a fake project */ project = new FreeStyleProject(Jenkins.getInstance(), "fake-" + UUID.randomUUID().toString()); } return new StandardListBoxModel() .includeEmptyValue() .includeMatchingAs( project instanceof Queue.Task ? Tasks.getAuthenticationOf((Queue.Task) project) : ACL.SYSTEM, project, StandardUsernameCredentials.class, GitURIRequirementsBuilder.fromUri(url).build(), GitClient.CREDENTIALS_MATCHER) .includeCurrentValue(credentialsId); }
/** * Creates a new builder with the same requirements as this builder. * * @return a new builder with the same requirements as this builder. */ @NonNull public GitURIRequirementsBuilder duplicate() { return new GitURIRequirementsBuilder(requirements); }