/** * 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(); }
@Deprecated public FormValidation doCheck(@AncestorInPath AbstractProject project, @QueryParameter String value) throws IOException { return doCheckTargets(project, value); }
public AutoCompletionCandidates doAutoCompleteProjectName(@QueryParameter String value) { return AutoCompletionCandidates.ofJobNames(Job.class, value, null, Jenkins.getInstance()); }
/** * Fails if a global view with the given name does not exist. */ public FormValidation doViewExistsCheck(@QueryParameter String value) { checkPermission(View.CREATE); String view = Util.fixEmpty(value); if(view==null) return FormValidation.ok(); if(Jenkins.getInstance().getView(view)!=null) return FormValidation.ok(); else return FormValidation.error(Messages.ProxyView_NoSuchViewExists(value)); }
/** * 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); }
/** * 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 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(); }
/** * Performs syntax check. */ public FormValidation doCheckSpec(@QueryParameter String value, @AncestorInPath Item item) { try { CronTabList ctl = CronTabList.create(fixNull(value), item != null ? Hash.from(item.getFullName()) : null); Collection<FormValidation> validations = new ArrayList<>(); updateValidationsForSanity(validations, ctl); updateValidationsForNextRun(validations, ctl); return FormValidation.aggregate(validations); } catch (ANTLRException e) { if (value.trim().indexOf('\n')==-1 && value.contains("**")) return FormValidation.error(Messages.TimerTrigger_MissingWhitespace()); return FormValidation.error(e.getMessage()); } }
/** * Auto-completion for the "copy from" field in the new job page. */ @Restricted(DoNotUse.class) public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@QueryParameter final String value, @AncestorInPath ItemGroup<?> container) { AutoCompletionCandidates candidates = AutoCompletionCandidates.ofJobNames(TopLevelItem.class, value, container); if (container instanceof DirectlyModifiableTopLevelItemGroup) { DirectlyModifiableTopLevelItemGroup modifiableContainer = (DirectlyModifiableTopLevelItemGroup) container; Iterator<String> it = candidates.getValues().iterator(); while (it.hasNext()) { TopLevelItem item = Jenkins.getInstance().getItem(it.next(), container, TopLevelItem.class); if (item == null) { continue; // ? } if (!modifiableContainer.canAdd(item)) { it.remove(); } } } return candidates; }
/** * 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())); }
/** * 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 doCheckAdminAddress(@QueryParameter String value) { try { new InternetAddress(value); return FormValidation.ok(); } catch (AddressException e) { return FormValidation.error(e.getMessage()); } }
/** * Configure the logging level. */ @edu.umd.cs.findbugs.annotations.SuppressFBWarnings("LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE") @RequirePOST public HttpResponse doConfigLogger(@QueryParameter String name, @QueryParameter String level) { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); Level lv; if(level.equals("inherit")) lv = null; else lv = Level.parse(level.toUpperCase(Locale.ENGLISH)); Logger.getLogger(name).setLevel(lv); return new HttpRedirect("levels"); }
public FormValidation doCheckLabel(@AncestorInPath AbstractProject<?,?> project, @QueryParameter String value) { return validateLabelExpression(value, project); }
public FormValidation doCheckTargets(@AncestorInPath AbstractProject<?,?> project, @QueryParameter String value) throws IOException { if (project == null) { return FormValidation.ok(); } return FilePath.validateFileMask(project.getSomeWorkspace(),value); }
/** * Checks to see if the candidate displayName collides with any * existing display names or project names * @param displayName The display name to test * @param jobName The name of the job the user is configuring */ public FormValidation doCheckDisplayName(@QueryParameter String displayName, @QueryParameter String jobName) { displayName = displayName.trim(); if(LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "Current job name is " + jobName); } if(!isNameUnique(displayName, jobName)) { return FormValidation.warning(Messages.Jenkins_CheckDisplayName_NameNotUniqueWarning(displayName)); } else if(!isDisplayNameUnique(displayName, jobName)){ return FormValidation.warning(Messages.Jenkins_CheckDisplayName_DisplayNameNotUniqueWarning(displayName)); } else { return FormValidation.ok(); } }
/** * Makes sure that the given name is good as an agent name. */ public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException { Jenkins.getInstance().checkPermission(Computer.CREATE); if(Util.fixEmpty(value)==null) return FormValidation.ok(); try { checkName(value); return FormValidation.ok(); } catch (Failure e) { return FormValidation.error(e.getMessage()); } }
public FormValidation doCheckCommand(@QueryParameter String value) { if (value.length() > 0) { return FormValidation.ok(); } else { return FormValidation.error(Messages.CommandInstaller_no_command()); } }
/** * Auto-completion for the "copy from" field in the new job page. */ public AutoCompletionCandidates doAutoCompleteCopyNewItemFrom(@QueryParameter final String value) { final AutoCompletionCandidates r = new AutoCompletionCandidates(); for (Node n : Jenkins.getInstance().getNodes()) { if (n.getNodeName().startsWith(value)) r.add(n.getNodeName()); } return r; } }
public AutoCompletionCandidates doAutoCompleteChildProjects(@QueryParameter String value, @AncestorInPath Item self, @AncestorInPath ItemGroup container) { return AutoCompletionCandidates.ofJobNames(Job.class,value,self,container); }