Refine search
/** * Validates the retry count Regex */ public FormValidation doCheckRetryCount(@QueryParameter String value)throws IOException,ServletException{ // retry count is optional so this is ok if(value == null || value.trim().equals("")) return FormValidation.ok(); if (!value.matches("[0-9]*")) { return FormValidation.error("Invalid retry count"); } return FormValidation.ok(); }
/** * Checks if the MAVEN_HOME is valid. */ @Override protected FormValidation checkHomeDirectory(File value) { File maven1File = new File(value,MAVEN_1_INSTALLATION_COMMON_FILE); File maven2File = new File(value,MAVEN_2_INSTALLATION_COMMON_FILE); if(!maven1File.exists() && !maven2File.exists()) return FormValidation.error(Messages.Maven_NotMavenDirectory(value)); return FormValidation.ok(); }
/** * Checks the URL in {@code global.jelly} */ public FormValidation doCheckUrl(@QueryParameter String value) { if(value.startsWith("http://localhost")) return FormValidation.warning(Messages.Mailer_Localhost_Error()); return FormValidation.ok(); }
public FormValidation doCheckNewSource(@QueryParameter String newSource){ Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); String normalized = Util.fixEmptyAndTrim(newSource); File f = new File(newSource); if (normalized == null) { return FormValidation.ok(); // empty, do nothing } else if (!f.exists() && !ConfigurationAsCode.isSupportedURI(normalized)) { return FormValidation.error("Configuration cannot be applied. File or URL cannot be parsed or do not exist."); } try { final Map<Source, String> issues = collectIssues(newSource); final JSONArray errors = collectProblems(issues, "error"); if (!errors.isEmpty()) { return FormValidation.error(errors.toString()); } final JSONArray warnings = collectProblems(issues, "warning"); if (!warnings.isEmpty()) { return FormValidation.warning(warnings.toString()); } return FormValidation.okWithMarkup("The configuration can be applied"); } catch (ConfiguratorException e) { return FormValidation.error(e, e.getCause().getMessage()); } catch (IllegalArgumentException e) { return FormValidation.error(e, e.getCause().getMessage()); } }
public FormValidation doCheckAcceptLicense(@QueryParameter boolean value) { if (username==null || password==null) return FormValidation.errorWithMarkup(Messages.JDKInstaller_RequireOracleAccount(Stapler.getCurrentRequest().getContextPath()+'/'+getDescriptorUrl()+"/enterCredential")); if (value) { return FormValidation.ok(); } else { return FormValidation.error(Messages.JDKInstaller_DescriptorImpl_doCheckAcceptLicense()); } }
/** * If the user chose the default JDK, make sure we got 'java' in PATH. */ public FormValidation doDefaultJDKCheck(StaplerRequest request, @QueryParameter String value) { if(!JDK.isDefaultName(value)) // assume the user configured named ones properly in system config --- // or else system config should have reported form field validation errors. return FormValidation.ok(); // default JDK selected. Does such java really exist? if(JDK.isDefaultJDKValid(Jenkins.this)) return FormValidation.ok(); else return FormValidation.errorWithMarkup(Messages.Hudson_NoJavaInPath(request.getContextPath())); }
public FormValidation doCheckAdminAddress(@QueryParameter String value) { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
/** * Checks if the JAVA_HOME is a valid JAVA_HOME path. */ @Override protected FormValidation checkHomeDirectory(File value) { File toolsJar = new File(value,"lib/tools.jar"); File mac = new File(value,"lib/dt.jar"); // JENKINS-25601: JDK 9+ no longer has tools.jar. Keep the existing dt.jar/tools.jar checks to be safe. File javac = new File(value, "bin/javac"); File javacExe = new File(value, "bin/javac.exe"); if(!toolsJar.exists() && !mac.exists() && !javac.exists() && !javacExe.exists()) return FormValidation.error(Messages.Hudson_NotJDKDir(value)); return FormValidation.ok(); }
/** * Performs on-the-fly validation of the file mask wildcard, when the artifacts * textbox or the caseSensitive checkbox are modified */ public FormValidation doCheckArtifacts(@AncestorInPath AbstractProject project, @QueryParameter String value, @QueryParameter(value = "caseSensitive") String caseSensitive) throws IOException { if (project == null) { return FormValidation.ok(); } // defensive approach to remain case sensitive in doubtful situations boolean bCaseSensitive = caseSensitive == null || !"false".equals(caseSensitive); return FilePath.validateFileMask(project.getSomeWorkspace(), value, bCaseSensitive); }
public FormValidation doCheckCommand(@QueryParameter String value) { if (value.length() > 0) { return FormValidation.ok(); } else { return FormValidation.error(Messages.CommandInstaller_no_command()); } }
/** * Makes sure that the given string is a non-negative integer. */ public static FormValidation validateNonNegativeInteger(String value) { try { if(Integer.parseInt(value)<0) return error(hudson.model.Messages.Hudson_NotANonNegativeNumber()); return ok(); } catch (NumberFormatException e) { return error(hudson.model.Messages.Hudson_NotANumber()); } }
public FormValidation doCheckTargets(@AncestorInPath AbstractProject<?,?> project, @QueryParameter String value) throws IOException { if (project == null) { return FormValidation.ok(); } return FilePath.validateFileMask(project.getSomeWorkspace(),value); }
public FormValidation doCheckToolHome(@QueryParameter String value) { if (value.length() > 0) { return FormValidation.ok(); } else { return FormValidation.error(Messages.CommandInstaller_no_command()); } } }
/** * Makes sure that the given string is a positive integer. */ public static FormValidation validatePositiveInteger(String value) { try { if(Integer.parseInt(value)<=0) return error(hudson.model.Messages.Hudson_NotAPositiveNumber()); return ok(); } catch (NumberFormatException e) { return error(hudson.model.Messages.Hudson_NotANumber()); } }
/** * Checks if the home directory is valid. * @since 1.563 */ public FormValidation doCheckHome(@QueryParameter File value) { // this can be used to check the existence of a file on the server, so needs to be protected Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); if (value.getPath().isEmpty()) { return FormValidation.ok(); } if (!value.isDirectory()) { return FormValidation.warning(Messages.ToolDescriptor_NotADirectory(value)); } return checkHomeDirectory(value); }
/** * Checks if the include regular expression is valid. */ public FormValidation doCheckIncludeRegex( @QueryParameter String value ) throws IOException, ServletException, InterruptedException { String v = Util.fixEmpty(value); if (v != null) { try { Pattern.compile(v); } catch (PatternSyntaxException pse) { return FormValidation.error(pse.getMessage()); } } return FormValidation.ok(); } }
/** * Performs syntax check. */ public FormValidation doCheckScmpoll_spec(@QueryParameter String value, @QueryParameter boolean ignorePostCommitHooks, @AncestorInPath Item item) { if (StringUtils.isBlank(value)) { if (ignorePostCommitHooks) { return FormValidation.ok(Messages.SCMTrigger_no_schedules_no_hooks()); } else { return FormValidation.ok(Messages.SCMTrigger_no_schedules_hooks()); } } else { return Jenkins.getInstance().getDescriptorByType(TimerTrigger.DescriptorImpl.class) .doCheckSpec(value, item); } } }
public FormValidation doCheckCustomWorkspace(@QueryParameter String customWorkspace){ if(Util.fixEmptyAndTrim(customWorkspace)==null) return FormValidation.error(Messages.AbstractProject_CustomWorkspaceEmpty()); else return FormValidation.ok(); }