Java Code Examples for hudson.util.FormValidation#ok()
The following examples show how to use
hudson.util.FormValidation#ok() .
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: ListGitBranchesParameterDefinition.java From list-git-branches-parameter-plugin with MIT License | 6 votes |
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 2
Source File: AwsKeyCredentials.java From jenkins-deployment-dashboard-plugin with MIT License | 6 votes |
public FormValidation doTestAwsConnection(@QueryParameter("key") final String accessKey, @QueryParameter("secret") final Secret secretKey) { LOGGER.info("Verify AWS connection key " + accessKey); FormValidation validationResult; try { final AWSCredentials awsCredentials = createCredentials(accessKey, secretKey.getPlainText()); final EC2Connector conn = new EC2Connector(new AmazonEC2Client(awsCredentials)); validationResult = conn.areAwsCredentialsValid() ? FormValidation.ok(Messages.AwsKeyCredentials_awsConnectionSuccessful()) : FormValidation.warning(Messages .AwsKeyCredentials_awsConnectionFailed()); } catch (Exception e) { LOGGER.severe(e.getMessage()); validationResult = FormValidation.error(Messages.AwsKeyCredentials_awsConnectionCritical() + e.getMessage()); } return validationResult; }
Example 3
Source File: AWSDeviceFarmRecorder.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 6 votes |
/** * Validate if user account has unmetered devices * * @param isRunUnmetered * @param appArtifact * @return Returns whether form validation passed */ @SuppressWarnings("unused") public FormValidation doCheckIsRunUnmetered(@QueryParameter Boolean isRunUnmetered, @QueryParameter String appArtifact, @QueryParameter Boolean ifWebApp) { if (isRunUnmetered != null && isRunUnmetered) { AWSDeviceFarm adf = getAWSDeviceFarm(); if (ifWebApp != null && !ifWebApp) { String os = null; try { os = adf.getOs(appArtifact); } catch (AWSDeviceFarmException e) { return FormValidation.error(e.getMessage()); } if (adf.getUnmeteredDevices(os) <= 0) { return FormValidation .error(String.format("Your account does not have unmetered %s device slots.", os)); } } else { if (adf.getUnmeteredDevicesForWeb() <= 0) { return FormValidation.error( String.format("Your account does not have unmetered Android or IOS device slots.")); } } } return FormValidation.ok(); }
Example 4
Source File: ModelValidation.java From warnings-ng-plugin with MIT License | 6 votes |
/** * Performs on-the-fly validation on the source code directory. * * @param project * the project * @param sourceDirectory * the file pattern * * @return the validation result */ public FormValidation doCheckSourceDirectory(@AncestorInPath final AbstractProject<?, ?> project, @QueryParameter final String sourceDirectory) { if (project != null) { // there is no workspace in pipelines try { FilePath workspace = project.getSomeWorkspace(); if (workspace != null && workspace.exists()) { return validateRelativePath(sourceDirectory, workspace); } } catch (InterruptedException | IOException ignore) { // ignore and return ok } } return FormValidation.ok(); }
Example 5
Source File: TestRailNotifier.java From testrail-jenkins-plugin with Apache License 2.0 | 6 votes |
public FormValidation doCheckTestrailHost(@QueryParameter String value) throws IOException, ServletException { if (value.length() == 0) { return FormValidation.warning("Please add your TestRail host URI."); } // TODO: There is probably a better way to do URL validation. if (!value.startsWith("http://") && !value.startsWith("https://")) { return FormValidation.error("Host must be a valid URL."); } testrail.setHost(value); testrail.setUser(""); testrail.setPassword(""); if (!testrail.serverReachable()) { return FormValidation.error("Host is not reachable."); } return FormValidation.ok(); }
Example 6
Source File: Site.java From jira-steps-plugin with Apache License 2.0 | 5 votes |
public FormValidation doValidateCredentials(@QueryParameter String url, @QueryParameter String credentialsId, @QueryParameter Integer timeout, @QueryParameter Integer readTimeout) throws IOException { FormValidation validation = doCheckUrl(url); if (validation.kind != Kind.OK) { return FormValidation.error(Messages.Site_emptyURL()); } validation = doCheckTimeout(timeout); if (validation.kind != Kind.OK) { return validation; } validation = doCheckReadTimeout(readTimeout); if (validation.kind != Kind.OK) { return validation; } Site site = new Site("test", new URL(url), LoginType.CREDENTIAL.name(), timeout); site.setCredentialsId(credentialsId); site.setReadTimeout(readTimeout); try { final JiraService service = new JiraService(site); final ResponseData<Map<String, Object>> response = service.getServerInfo(); if (response.isSuccessful()) { Map<String, Object> data = response.getData(); return FormValidation.ok(Messages.Site_testSuccess(data.get("serverTitle"), data.get("version"))); } else { return FormValidation.error(response.getError()); } } catch (Exception e) { log.log(Level.WARNING, Messages.Site_testFail(url), e); } return FormValidation.error(Messages.Site_testFail(url)); }
Example 7
Source File: ParamVerify.java From jenkins-plugin with Apache License 2.0 | 5 votes |
public static FormValidation doCheckForWaitTime(String value) { value = (value == null) ? "" : value.trim(); if (value.isEmpty()) // timeout will fallthrough to default return FormValidation.ok(); try { Long.parseLong(value); } catch (Throwable t) { return FormValidation .ok("Non-numeric value specified. During execution, an attempt will be made to resolve [%s] as a build parameter or Jenkins global variable.", value); } return FormValidation.ok(); }
Example 8
Source File: AWSCodePipelineSCM.java From aws-codepipeline-plugin-for-jenkins with Apache License 2.0 | 5 votes |
public FormValidation doCheckProxyPort(@QueryParameter final String value) { if (value == null || value.isEmpty()) { return FormValidation.ok(); } return validateIntIsInRange(value, 0, 65535, "Proxy Port", "Proxy Port must be between 0 and 65535"); }
Example 9
Source File: GitHubSCMSource.java From github-branch-source-plugin with MIT License | 5 votes |
@Restricted(NoExternalUse.class) public FormValidation doCheckIncludes(@QueryParameter String value) { if (value.isEmpty()) { return FormValidation.warning(Messages.GitHubSCMSource_did_you_mean_to_use_to_match_all_branches()); } return FormValidation.ok(); }
Example 10
Source File: RequiredResourcesProperty.java From lockable-resources-plugin with MIT License | 5 votes |
public FormValidation doCheckResourceNames(@QueryParameter String value, @QueryParameter String labelName, @QueryParameter boolean script) { String labelVal = Util.fixEmptyAndTrim(labelName); String names = Util.fixEmptyAndTrim(value); if (names == null) { return FormValidation.ok(); } else if (labelVal != null || script) { return FormValidation.error( "Only label, groovy expression, or resources can be defined, not more than one."); } else { List<String> wrongNames = new ArrayList<>(); for (String name : names.split("\\s+")) { boolean found = false; for (LockableResource r : LockableResourcesManager.get() .getResources()) { if (r.getName().equals(name)) { found = true; break; } } if (!found) wrongNames.add(name); } if (wrongNames.isEmpty()) { return FormValidation.ok(); } else { return FormValidation .error("The following resources do not exist: " + wrongNames); } } }
Example 11
Source File: ContainerTemplate.java From kubernetes-plugin with Apache License 2.0 | 5 votes |
public FormValidation doCheckImage(@QueryParameter String value) { if (StringUtils.isEmpty(value)) { return FormValidation.ok("Image is mandatory"); } else if (PodTemplateUtils.validateImage(value)) { return FormValidation.ok(); } else { return FormValidation.error("Malformed image"); } }
Example 12
Source File: AWSDeviceFarmRecorder.java From aws-device-farm-jenkins-plugin with Apache License 2.0 | 5 votes |
/** * Validate the user entered artifact for Appium Node test content. * * @param appiumNodeTest The path to the test file. * @return Whether or not the form was ok. */ @SuppressWarnings("unused") public FormValidation doCheckAppiumNodeTest(@QueryParameter String appiumNodeTest) { if (appiumNodeTest == null || appiumNodeTest.isEmpty()) { return FormValidation.error("Required!"); } return FormValidation.ok(); }
Example 13
Source File: GitHubAppCredentials.java From github-branch-source-plugin with MIT License | 5 votes |
public FormValidation doCheckAppID(@QueryParameter String appID) { if (!appID.isEmpty()) { try { Integer.parseInt(appID); } catch (NumberFormatException x) { return FormValidation.warning("An app ID is likely to be a number, distinct from the app name"); } } return FormValidation.ok(); }
Example 14
Source File: AppCenterRecorder.java From appcenter-plugin with MIT License | 5 votes |
@SuppressWarnings("unused") public FormValidation doCheckAppName(@QueryParameter String value) { if (value.isEmpty()) { return FormValidation.error(Messages.AppCenterRecorder_DescriptorImpl_errors_missingAppName()); } final Validator validator = new AppNameValidator(); if (!validator.isValid(value)) { return FormValidation.error(Messages.AppCenterRecorder_DescriptorImpl_errors_invalidAppName()); } return FormValidation.ok(); }
Example 15
Source File: GroovyParser.java From warnings-ng-plugin with MIT License | 5 votes |
private FormValidation createOkMessage(final Issue issue) { StringBuilder okMessage = new StringBuilder(Messages.GroovyParser_Error_Example_ok_title()); message(okMessage, Messages.GroovyParser_Error_Example_ok_file(issue.getFileName())); message(okMessage, Messages.GroovyParser_Error_Example_ok_line(issue.getLineStart())); message(okMessage, Messages.GroovyParser_Error_Example_ok_priority(issue.getSeverity())); message(okMessage, Messages.GroovyParser_Error_Example_ok_category(issue.getCategory())); message(okMessage, Messages.GroovyParser_Error_Example_ok_type(issue.getType())); message(okMessage, Messages.GroovyParser_Error_Example_ok_message(issue.getMessage())); return FormValidation.ok(okMessage.toString()); }
Example 16
Source File: GitHubBranchRepository.java From github-integration-plugin with MIT License | 5 votes |
@Override @RequirePOST public FormValidation doRebuild(StaplerRequest req) throws IOException { FormValidation result; try { if (!job.hasPermission(Item.BUILD)) { return FormValidation.error("Forbidden"); } final String param = "branchName"; String branchName = ""; if (req.hasParameter(param)) { branchName = req.getParameter(param); } Map<String, List<Run<?, ?>>> allBuilds = getAllBranchBuilds(); List<Run<?, ?>> branchBuilds = allBuilds.get(branchName); if (branchBuilds != null && !allBuilds.isEmpty()) { if (rebuild(branchBuilds.get(0))) { result = FormValidation.ok("Rebuild scheduled"); } else { result = FormValidation.warning("Rebuild not scheduled"); } } else { result = FormValidation.warning("Build not found"); } } catch (Exception e) { LOG.error("Can't start rebuild", e.getMessage()); result = FormValidation.error(e, "Can't start rebuild: " + e.getMessage()); } return result; }
Example 17
Source File: TelegramBotGlobalConfiguration.java From telegram-notifications-plugin with MIT License | 4 votes |
public FormValidation doCheckMessage(@QueryParameter String value) throws IOException, ServletException { return value.length() == 0 ? FormValidation.error("Please set a message") : FormValidation.ok(); }
Example 18
Source File: ParamVerify.java From jenkins-plugin with Apache License 2.0 | 4 votes |
public static FormValidation doCheckToken(String value) { if (value.length() == 0) return FormValidation .warning("Unless you specify a value here, the default token will be used; see this field's help or https://github.com/openshift/jenkins-plugin#common-aspects-across-the-rest-based-functions-build-steps-scm-post-build-actions for details"); return FormValidation.ok(); }
Example 19
Source File: ParamVerify.java From jenkins-plugin with Apache License 2.0 | 4 votes |
public static FormValidation doCheckBldCfg(@QueryParameter String value) { if (value.length() == 0) return FormValidation.error("You must set a BuildConfig name"); return FormValidation.ok(); }
Example 20
Source File: MarathonBuilder.java From marathonv5 with Apache License 2.0 | 4 votes |
public FormValidation doCheckTestCases(@QueryParameter String testCases, @AncestorInPath AbstractProject<?, ?> project) throws IOException, ServletException { if (testCases.length() == 0) return FormValidation.warning("Please enter test case to run."); return FormValidation.ok(); }