org.kohsuke.stapler.AncestorInPath Java Examples

The following examples show how to use org.kohsuke.stapler.AncestorInPath. 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: Site.java    From jira-steps-plugin with Apache License 2.0 6 votes vote down vote up
public FormValidation doCheckCredentialsId(@AncestorInPath Item item,
    final @QueryParameter String credentialsId,
    final @QueryParameter String url) {

  if (item == null) {
    if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
      return FormValidation.ok();
    }
  } else if (!item.hasPermission(Item.EXTENDED_READ) && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
    return FormValidation.ok();
  }
  if (StringUtils.isBlank(credentialsId)) {
    return FormValidation.warning(Messages.Site_emptyCredentialsId());
  }

  List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(url).build();
  if (CredentialsProvider.listCredentials(StandardUsernameCredentials.class, item, getAuthentication(item), domainRequirements, CredentialsMatchers.withId(credentialsId)).isEmpty()) {
    return FormValidation.error(Messages.Site_invalidCredentialsId());
  }
  return FormValidation.ok();
}
 
Example #2
Source File: ConduitCredentialsDescriptor.java    From phabricator-jenkins-plugin with MIT License 6 votes vote down vote up
public static ListBoxModel doFillCredentialsIDItems(@AncestorInPath Jenkins context) {
    if (context == null || !context.hasPermission(Item.CONFIGURE)) {
        return new StandardListBoxModel();
    }

    List<DomainRequirement> domainRequirements = new ArrayList<DomainRequirement>();
    return new StandardListBoxModel()
            .withEmptySelection()
            .withMatching(
                    CredentialsMatchers.anyOf(
                            CredentialsMatchers.instanceOf(ConduitCredentials.class)),
                    CredentialsProvider.lookupCredentials(
                            StandardCredentials.class,
                            context,
                            ACL.SYSTEM,
                            domainRequirements));
}
 
Example #3
Source File: AxivionSuite.java    From warnings-ng-plugin with MIT License 6 votes vote down vote up
/**
 * Shows the user all available credential id items.
 *
 * @param item
 *         jenkins configuration
 * @param credentialsId
 *         current used credentials
 *
 * @return a list view of all credential ids
 */
public ListBoxModel doFillCredentialsIdItems(
        @AncestorInPath final Item item, @QueryParameter final String credentialsId) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (item == null) {
        if (!new JenkinsFacade().hasPermission(Jenkins.ADMINISTER)) {
            return result.includeCurrentValue(credentialsId);
        }
    }
    else {
        if (!item.hasPermission(Item.EXTENDED_READ)
                && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
            return result.includeCurrentValue(credentialsId);
        }
    }
    return result.includeAs(
            ACL.SYSTEM,
            item,
            StandardUsernamePasswordCredentials.class,
            Collections.emptyList())
            .includeCurrentValue(credentialsId);
}
 
Example #4
Source File: GitLabSCMSource.java    From gitlab-branch-source-plugin with MIT License 6 votes vote down vote up
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context,
        @QueryParameter String serverName, @QueryParameter String credentialsId) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (context == null) {
        // must have admin if you want the list without a context
        if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
            result.includeCurrentValue(credentialsId);
            return result;
        }
    } else {
        if (!context.hasPermission(Item.EXTENDED_READ)
                && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
            // must be able to read the configuration or use the item credentials if you
            // want the list
            result.includeCurrentValue(credentialsId);
            return result;
        }
    }
    result.includeEmptyValue();
    result.includeMatchingAs(
            context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM,
            context, StandardUsernameCredentials.class, fromUri(getServerUrlFromName(serverName)).build(),
            GitClient.CREDENTIALS_MATCHER);
    return result;
}
 
Example #5
Source File: BitbucketBuildStatusNotifier.java    From bitbucket-build-status-notifier-plugin with MIT License 6 votes vote down vote up
public FormValidation doCheckCredentialsId(@QueryParameter final String credentialsId,
                                           @AncestorInPath final Job<?,?> owner) {
    String globalCredentialsId = this.getGlobalCredentialsId();

    if (credentialsId == null || credentialsId.isEmpty()) {
        if (globalCredentialsId == null || globalCredentialsId.isEmpty()) {
            return FormValidation.error("Please enter Bitbucket OAuth credentials");
        } else {
            return this.doCheckGlobalCredentialsId(this.getGlobalCredentialsId());
        }
    }

    UsernamePasswordCredentials credentials = BitbucketBuildStatusHelper.getCredentials(credentialsId, owner);

    return this.checkCredentials(credentials);
}
 
Example #6
Source File: ModelValidation.java    From warnings-ng-plugin with MIT License 6 votes vote down vote up
/**
 * Performs on-the-fly validation on the ant pattern for input files.
 *
 * @param project
 *         the project
 * @param pattern
 *         the file pattern
 *
 * @return the validation result
 */
public FormValidation doCheckPattern(@AncestorInPath final AbstractProject<?, ?> project,
        @QueryParameter final String pattern) {
    if (project != null) { // there is no workspace in pipelines
        try {
            FilePath workspace = project.getSomeWorkspace();
            if (workspace != null && workspace.exists()) {
                return validatePatternInWorkspace(pattern, workspace);
            }
        }
        catch (InterruptedException | IOException ignore) {
            // ignore and return ok
        }
    }

    return FormValidation.ok();
}
 
Example #7
Source File: KubernetesCloud.java    From kubernetes-plugin with Apache License 2.0 6 votes vote down vote up
@RequirePOST
@SuppressWarnings("unused") // used by jelly
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context, @QueryParameter String serverUrl) {
    Jenkins.get().checkPermission(Jenkins.ADMINISTER);
    StandardListBoxModel result = new StandardListBoxModel();
    result.includeEmptyValue();
    result.includeMatchingAs(
        ACL.SYSTEM,
        context,
        StandardCredentials.class,
        serverUrl != null ? URIRequirementBuilder.fromUri(serverUrl).build()
                    : Collections.EMPTY_LIST,
        CredentialsMatchers.anyOf(
            AuthenticationTokens.matcher(KubernetesAuth.class)
        )
    );
    return result;
}
 
Example #8
Source File: ListGitBranchesParameterDefinition.java    From list-git-branches-parameter-plugin with MIT License 6 votes vote down vote up
public FormValidation doCheckRemoteURL(StaplerRequest req, @AncestorInPath Item context, @QueryParameter String value) {
    String url = Util.fixEmptyAndTrim(value);

    if (url == null) {
        return FormValidation.error("Repository URL is required");
    }

    if (url.indexOf('$') != -1) {
        return FormValidation.warning("This repository URL is parameterized, syntax validation skipped");
    }

    try {
        new URIish(value);
    } catch (URISyntaxException e) {
        return FormValidation.error("Repository URL is illegal");
    }
    return FormValidation.ok();
}
 
Example #9
Source File: ListGitBranchesParameterDefinition.java    From list-git-branches-parameter-plugin with MIT License 6 votes vote down vote up
public ListBoxModel doFillValueItems(@AncestorInPath Job<?, ?> context, @QueryParameter String param)
        throws IOException, InterruptedException {
    ListBoxModel items = new ListBoxModel();
    if (context != null && context.hasPermission(Item.BUILD)) {
        ParametersDefinitionProperty prop = context.getProperty(ParametersDefinitionProperty.class);
        if (prop != null) {
            ParameterDefinition def = prop.getParameterDefinition(param);
            if (def instanceof ListGitBranchesParameterDefinition) {
                Map<String, String> paramList = ((ListGitBranchesParameterDefinition) def).generateContents(context);
                for (Map.Entry<String, String> entry : paramList.entrySet()) {
                    items.add(entry.getValue(), entry.getKey());
                }
            }
        }
    }
    return items;
}
 
Example #10
Source File: GlobalKafkaConfiguration.java    From remoting-kafka-plugin with MIT License 6 votes vote down vote up
private FormValidation checkCredentialsId(@AncestorInPath Item item, @QueryParameter String value) {
    if (item == null) {
        if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
            return FormValidation.ok();
        }
    }
    if (value.startsWith("${") && value.endsWith("}")) {
        return FormValidation.warning("Cannot validate expression based credentials");
    }
    if (CredentialsProvider.listCredentials(
            StandardUsernamePasswordCredentials.class,
            Jenkins.get(),
            ACL.SYSTEM,
            Collections.singletonList(KAFKA_SCHEME),
            CredentialsMatchers.withId(value)
    ).isEmpty()) {
        return FormValidation.error("Cannot find currently selected credentials");
    }
    return FormValidation.ok();
}
 
Example #11
Source File: GlobalKafkaConfiguration.java    From remoting-kafka-plugin with MIT License 6 votes vote down vote up
private ListBoxModel fillCredentialsIdItems(@AncestorInPath Item item, @QueryParameter String credentialsId) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (item == null) {
        if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
            return result.includeCurrentValue(credentialsId);
        }
    }
    return result
            .includeMatchingAs(
                    ACL.SYSTEM,
                    Jenkins.get(),
                    StandardUsernamePasswordCredentials.class,
                    Collections.singletonList(KAFKA_SCHEME),
                    CredentialsMatchers.always()
            )
            .includeCurrentValue(credentialsId);
}
 
Example #12
Source File: BuildStatusConfig.java    From github-autostatus-plugin with MIT License 6 votes vote down vote up
/**
 * Validates the credentials id.
 *
 * @param item context for validation
 * @param value to validate
 * @return FormValidation
 */
public FormValidation doCheckCredentialsId(@AncestorInPath Item item, @QueryParameter String value) {
    if (item == null) {
        if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
            return FormValidation.ok();
        }
    } else {
        if (!item.hasPermission(Item.EXTENDED_READ)
                && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
            return FormValidation.ok();
        }
    }
    if (StringUtils.isEmpty(value)) {
        return FormValidation.ok();
    }
    if (null == getCredentials(UsernamePasswordCredentials.class, value)) {
        return FormValidation.error("Cannot find currently selected credentials");
    }
    return FormValidation.ok();
}
 
Example #13
Source File: GitLabSCMSourceSettings.java    From gitlab-branch-source-plugin with GNU General Public License v2.0 6 votes vote down vote up
@Restricted(NoExternalUse.class)
public ListBoxModel doFillCheckoutCredentialsIdItems(@AncestorInPath SCMSourceOwner context, @QueryParameter String connectionName, @QueryParameter String checkoutCredentialsId) {
    if (context == null && !Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER) ||
            context != null && !context.hasPermission(Item.EXTENDED_READ)) {
        return new StandardListBoxModel().includeCurrentValue(checkoutCredentialsId);
    }

    StandardListBoxModel result = new StandardListBoxModel();
    result.add("- anonymous -", CHECKOUT_CREDENTIALS_ANONYMOUS);
    return result.includeMatchingAs(
            context instanceof Queue.Task
                    ? Tasks.getDefaultAuthenticationOf((Queue.Task) context)
                    : ACL.SYSTEM,
            context,
            StandardUsernameCredentials.class,
            SettingsUtils.gitLabConnectionRequirements(connectionName),
            GitClient.CREDENTIALS_MATCHER
    );
}
 
Example #14
Source File: BuildScanner.java    From acunetix-plugin with MIT License 6 votes vote down vote up
public ListBoxModel doFillGApiKeyIDItems(
        @AncestorInPath Item item) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (item == null) {
        if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
            return result.includeCurrentValue(gApiKeyID);
        }
    } else {
        if (!item.hasPermission(Item.EXTENDED_READ)
                && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
            return result.includeCurrentValue(gApiKeyID);
        }
    }
    if (gApiKeyID != null) {
        result.includeMatchingAs(ACL.SYSTEM, Jenkins.getInstance(), StringCredentials.class,
                Collections.<DomainRequirement> emptyList(), CredentialsMatchers.allOf(CredentialsMatchers.withId(gApiKeyID)));
    }
    return result
            .includeMatchingAs(ACL.SYSTEM, Jenkins.getInstance(), StringCredentials.class,
                    Collections.<DomainRequirement> emptyList(), CredentialsMatchers.allOf(CredentialsMatchers.instanceOf(StringCredentials.class)));
}
 
Example #15
Source File: ViolationsToBitbucketServerConfig.java    From violation-comments-to-stash-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused") // Used by stapler
public ListBoxModel doFillCredentialsIdItems(
    @AncestorInPath final Item item,
    @QueryParameter final String credentialsId,
    @QueryParameter final String bitbucketServerUrl) {
  return CredentialsHelper.doFillCredentialsIdItems(item, credentialsId, bitbucketServerUrl);
}
 
Example #16
Source File: WithMavenStep.java    From pipeline-maven-plugin with MIT License 5 votes vote down vote up
@Restricted(NoExternalUse.class) // Only for UI calls
public ListBoxModel doFillPublisherStrategyItems(@AncestorInPath ItemGroup context) {
    ListBoxModel r = new ListBoxModel();
    for(MavenPublisherStrategy publisherStrategy: MavenPublisherStrategy.values()) {
        r.add(publisherStrategy.getDescription(), publisherStrategy.name());
    }
    return r;
}
 
Example #17
Source File: ViolationsToBitbucketServerConfig.java    From violation-comments-to-stash-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused") // Used by stapler
public FormValidation doCheckCredentialsId(
    @AncestorInPath final Item item,
    @QueryParameter final String value,
    @QueryParameter final String bitbucketServerUrl) {
  return CredentialsHelper.doCheckFillCredentialsId(item, value, bitbucketServerUrl);
}
 
Example #18
Source File: GitHubStatusNotificationStep.java    From pipeline-githubnotify-step-plugin with MIT License 5 votes vote down vote up
@RequirePOST
public FormValidation doTestConnection(@QueryParameter ("credentialsId") final String credentialsId, @QueryParameter ("gitApiUrl") final String gitApiUrl, @AncestorInPath Item context) {
    context.checkPermission(Item.CONFIGURE);
    try {
        getGitHubIfValid(credentialsId, gitApiUrl, context);
        return FormValidation.ok("Success");
    } catch (Exception e) {
        return FormValidation.error(e.getMessage());
    }
}
 
Example #19
Source File: GitHubStatusNotificationStep.java    From pipeline-githubnotify-step-plugin with MIT License 5 votes vote down vote up
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath Item project) {
    AbstractIdCredentialsListBoxModel result = new StandardListBoxModel();
    if (!project.hasPermission(Item.CONFIGURE)) {
        return result;
    }
    List<UsernamePasswordCredentials> credentialsList = CredentialsProvider.lookupCredentials(UsernamePasswordCredentials.class, project, ACL.SYSTEM);
    for (UsernamePasswordCredentials credential : credentialsList) {
        result = result.with((IdCredentials) credential);
    }
    return result;
}
 
Example #20
Source File: DockerRegistryCredential.java    From yet-another-docker-plugin with MIT License 5 votes vote down vote up
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath ItemGroup context) {
    List<DockerRegistryAuthCredentials> credentials =
            CredentialsProvider.lookupCredentials(DockerRegistryAuthCredentials.class, context, ACL.SYSTEM,
                    Collections.emptyList());

    return new CredentialsListBoxModel()
            .includeEmptyValue()
            .withMatching(CredentialsMatchers.always(), credentials);
}
 
Example #21
Source File: VaultConfiguration.java    From hashicorp-vault-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused") // used by stapler
public ListBoxModel doFillVaultCredentialIdItems(@AncestorInPath Item item,
    @QueryParameter String uri) {
    // This is needed for folders: credentials bound to a folder are
    // realized through domain requirements
    List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(uri).build();
    return new StandardListBoxModel().includeEmptyValue().includeAs(ACL.SYSTEM, item,
        VaultCredential.class, domainRequirements);
}
 
Example #22
Source File: GitHubSCMNavigator.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Populates the drop-down list of credentials.
 *
 * @param context the context.
 * @param apiUri  the end-point.
 * @param credentialsId the existing selection;
 * @return the drop-down list.
 * @since 2.2.0
 */
@Restricted(NoExternalUse.class) // stapler
public ListBoxModel doFillCredentialsIdItems(@CheckForNull @AncestorInPath Item context,
                                             @QueryParameter String apiUri,
                                             @QueryParameter String credentialsId) {
    if (context == null
            ? !Jenkins.get().hasPermission(Jenkins.ADMINISTER)
            : !context.hasPermission(Item.EXTENDED_READ)) {
        return new StandardListBoxModel().includeCurrentValue(credentialsId);
    }
    return Connector.listScanCredentials(context, apiUri);
}
 
Example #23
Source File: ViolationsToGitHubConfiguration.java    From violation-comments-to-github-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused") // Used by stapler
public FormValidation doCheckCredentialsId(
    @AncestorInPath final Item item,
    @QueryParameter final String value,
    @QueryParameter final String gitHubUrl) {
  return CredentialsHelper.doCheckFillCredentialsId(item, value, gitHubUrl);
}
 
Example #24
Source File: ViolationsToGitHubConfiguration.java    From violation-comments-to-github-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused") // Used by stapler
public ListBoxModel doFillCredentialsIdItems(
    @AncestorInPath final Item item,
    @QueryParameter final String credentialsId,
    @QueryParameter final String gitHubUrl) {
  return CredentialsHelper.doFillCredentialsIdItems(item, credentialsId, gitHubUrl);
}
 
Example #25
Source File: ViolationsToGitHubConfig.java    From violation-comments-to-github-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused") // Used by stapler
public FormValidation doCheckCredentialsId(
    @AncestorInPath final Item item,
    @QueryParameter final String value,
    @QueryParameter final String gitHubUrl) {
  return CredentialsHelper.doCheckFillCredentialsId(item, value, gitHubUrl);
}
 
Example #26
Source File: SSHCheckoutTrait.java    From github-branch-source-plugin with MIT License 5 votes vote down vote up
/**
 * Validation for checkout credentials.
 *
 * @param context   the context.
 * @param serverUrl the server url.
 * @param value     the current selection.
 * @return the validation results
 */
@Restricted(NoExternalUse.class)
@SuppressWarnings("unused") // stapler form binding
public FormValidation doCheckCredentialsId(@CheckForNull @AncestorInPath Item context,
                                           @QueryParameter String serverUrl,
                                           @QueryParameter String value) {
    if (context == null
            ? !Jenkins.get().hasPermission(Jenkins.ADMINISTER)
            : !context.hasPermission(Item.EXTENDED_READ)) {
        return FormValidation.ok();
    }
    if (StringUtils.isBlank(value)) {
        // use agent key
        return FormValidation.ok();
    }
    if (CredentialsMatchers.firstOrNull(CredentialsProvider.lookupCredentials(
            SSHUserPrivateKey.class,
            context,
            context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM,
            URIRequirementBuilder.fromUri(serverUrl).build()),
            CredentialsMatchers.withId(value)) != null) {
        return FormValidation.ok();
    }
    if (CredentialsMatchers.firstOrNull(CredentialsProvider.lookupCredentials(
            StandardUsernameCredentials.class,
            context,
            context instanceof Queue.Task ? ((Queue.Task) context).getDefaultAuthentication() : ACL.SYSTEM,
            URIRequirementBuilder.fromUri(serverUrl).build()),
            CredentialsMatchers.withId(value)) != null) {
        return FormValidation.error(Messages.SSHCheckoutTrait_incompatibleCredentials());
    }
    return FormValidation.warning(Messages.SSHCheckoutTrait_missingCredentials());
}
 
Example #27
Source File: ViolationsToGitHubConfig.java    From violation-comments-to-github-plugin with MIT License 5 votes vote down vote up
@SuppressWarnings("unused") // Used by stapler
public ListBoxModel doFillCredentialsIdItems(
    @AncestorInPath final Item item,
    @QueryParameter final String credentialsId,
    @QueryParameter final String gitHubUrl) {
  return CredentialsHelper.doFillCredentialsIdItems(item, credentialsId, gitHubUrl);
}
 
Example #28
Source File: Site.java    From jira-steps-plugin with Apache License 2.0 5 votes vote down vote up
public ListBoxModel doFillCredentialsIdItems(final @AncestorInPath Item item,
    @QueryParameter String credentialsId,
    final @QueryParameter String url) {

  StandardListBoxModel result = new StandardListBoxModel();

  credentialsId = StringUtils.trimToEmpty(credentialsId);
  if (item == null) {
    if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
      return result.includeCurrentValue(credentialsId);
    }
  } else {
    if (!item.hasPermission(Item.EXTENDED_READ) && !item.hasPermission(CredentialsProvider.USE_ITEM)) {
      return result.includeCurrentValue(credentialsId);
    }
  }

  Authentication authentication = getAuthentication(item);
  List<DomainRequirement> domainRequirements = URIRequirementBuilder.fromUri(url).build();
  CredentialsMatcher always = CredentialsMatchers.always();
  Class<? extends StandardUsernameCredentials> type = UsernamePasswordCredentialsImpl.class;

  result.includeEmptyValue();
  if (item != null) {
    result.includeMatchingAs(authentication, item, type, domainRequirements, always);
  } else {
    result.includeMatchingAs(authentication, Jenkins.get(), type, domainRequirements, always);
  }
  return result;
}
 
Example #29
Source File: GitLabSCMNavigator.java    From gitlab-branch-source-plugin with MIT License 5 votes vote down vote up
public ListBoxModel doFillCredentialsIdItems(@AncestorInPath SCMSourceOwner context,
    @QueryParameter String serverName,
    @QueryParameter String credentialsId) {
    StandardListBoxModel result = new StandardListBoxModel();
    if (context == null) {
        if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) {
            // must have admin if you want the list without a context
            result.includeCurrentValue(credentialsId);
            return result;
        }
    } else {
        if (!context.hasPermission(Item.EXTENDED_READ)
            && !context.hasPermission(CredentialsProvider.USE_ITEM)) {
            // must be able to read the configuration or use the item credentials if you want the list
            result.includeCurrentValue(credentialsId);
            return result;
        }
    }
    result.includeEmptyValue();
    result.includeMatchingAs(
        context instanceof Queue.Task
            ? ((Queue.Task) context).getDefaultAuthentication()
            : ACL.SYSTEM,
        context,
        StandardUsernameCredentials.class,
        fromUri(getServerUrlFromName(serverName)).build(),
        GitClient.CREDENTIALS_MATCHER
    );
    return result;
}
 
Example #30
Source File: GitHubStatusNotificationStep.java    From pipeline-githubnotify-step-plugin with MIT License 5 votes vote down vote up
@RequirePOST
public FormValidation doCheckSha(@QueryParameter ("credentialsId") final String credentialsId, @QueryParameter ("repo") final String repo,
                                 @QueryParameter ("sha") final String sha, @QueryParameter ("account") final String account, @QueryParameter ("gitApiUrl") final String gitApiUrl, @AncestorInPath Item context) {
    context.checkPermission(Item.CONFIGURE);
    try {
        getCommitIfValid(credentialsId, gitApiUrl, account, repo, sha, context);
        return FormValidation.ok("Commit seems valid");

    } catch (Exception e) {
        return FormValidation.error(e.getMessage());
    }
}