public static FormValidation warning(String format, Object... args) { return warning(String.format(format,args)); }
public static FormValidation warning(Throwable e, String format, Object... args) { return warning(e,String.format(format,args)); }
/** * 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(); }
private void updateValidationsForSanity(Collection<FormValidation> validations, CronTabList ctl) { String msg = ctl.checkSanity(); if(msg!=null) validations.add(FormValidation.warning(msg)); }
private void updateValidationsForNextRun(Collection<FormValidation> validations, CronTabList ctl) { try { Calendar prev = ctl.previous(); Calendar next = ctl.next(); if (prev != null && next != null) { DateFormat fmt = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL); validations.add(FormValidation.ok(Messages.TimerTrigger_would_last_have_run_at_would_next_run_at(fmt.format(prev.getTime()), fmt.format(next.getTime())))); } else { validations.add(FormValidation.warning(Messages.TimerTrigger_no_schedules_so_will_never_run())); } } catch (RareOrImpossibleDateException ex) { validations.add(FormValidation.warning(Messages.TimerTrigger_the_specified_cron_tab_is_rare_or_impossible())); } } }
/** * Performs syntactical check on the remote FS for agents. */ public FormValidation doCheckRemoteFS(@QueryParameter String value) throws IOException, ServletException { if(Util.fixEmptyAndTrim(value)==null) return FormValidation.error(Messages.Slave_Remote_Director_Mandatory()); if(value.startsWith("\\\\") || value.startsWith("/net/")) return FormValidation.warning(Messages.Slave_Network_Mounted_File_System_Warning()); if (Util.isRelativePath(value)) { return FormValidation.warning(Messages.Slave_Remote_Relative_Path_Warning()); } return FormValidation.ok(); }
/** * 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(); } }
/** * 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); }
/** * Performs syntax check. */ public FormValidation doCheck(@QueryParameter String value) { try { String msg = CronTabList.create(fixNull(value)).checkSanity(); if (msg != null) return FormValidation.warning(msg); return FormValidation.ok(); } catch (ANTLRException e) { return FormValidation.error(e.getMessage()); } } }
return FormValidation.error(errorText); if (warningText != null) return FormValidation.warning(warningText); return FormValidation.error("No error or warning text was set for fieldCheck().");
/** * Validation of the display name field. * * @param view the view to check the new display name of. * @param value the proposed new display name. * @return the validation result. * @since 2.37 */ @SuppressWarnings("unused") // expose utility check method to subclasses protected FormValidation checkDisplayName(@Nonnull View view, @CheckForNull String value) { if (StringUtils.isBlank(value)) { // no custom name, no need to check return FormValidation.ok(); } for (View v: view.owner.getViews()) { if (v.getViewName().equals(view.getViewName())) { continue; } if (StringUtils.equals(v.getDisplayName(), value)) { return FormValidation.warning(Messages.View_DisplayNameNotUniqueWarning(value)); } } return FormValidation.ok(); }
/** * Performs on-the-fly validation of the errorlevel. */ @Restricted(DoNotUse.class) public FormValidation doCheckUnstableReturn(@QueryParameter String value) { value = Util.fixEmptyAndTrim(value); if (value == null) { return FormValidation.ok(); } long unstableReturn; try { unstableReturn = Long.parseLong(value); } catch (NumberFormatException e) { return FormValidation.error(hudson.model.Messages.Hudson_NotANumber()); } if (unstableReturn == 0) { return FormValidation.warning(hudson.tasks.Messages.BatchFile_invalid_exit_code_zero()); } if (unstableReturn < Integer.MIN_VALUE || unstableReturn > Integer.MAX_VALUE) { return FormValidation.error(hudson.tasks.Messages.BatchFile_invalid_exit_code_range(unstableReturn)); } return FormValidation.ok(); }
/** * Performs on-the-fly validation of the exit code. */ @Restricted(DoNotUse.class) public FormValidation doCheckUnstableReturn(@QueryParameter String value) { value = Util.fixEmptyAndTrim(value); if (value == null) { return FormValidation.ok(); } long unstableReturn; try { unstableReturn = Long.parseLong(value); } catch (NumberFormatException e) { return FormValidation.error(hudson.model.Messages.Hudson_NotANumber()); } if (unstableReturn == 0) { return FormValidation.warning(hudson.tasks.Messages.Shell_invalid_exit_code_zero()); } if (unstableReturn < 1 || unstableReturn > 255) { return FormValidation.error(hudson.tasks.Messages.Shell_invalid_exit_code_range(unstableReturn)); } return FormValidation.ok(); }
/** * Checks the GLOB-style file mask. See {@link #validateAntFileMask(String)}. * Requires configure permission on ancestor AbstractProject object in request, * or admin permission if no such ancestor is found. * @since 1.294 */ public FormValidation validateFileMask(String value, boolean errorIfNotExist, boolean caseSensitive) throws IOException { checkPermissionForValidate(); value = fixEmpty(value); if(value==null) return FormValidation.ok(); try { if(!exists()) // no workspace. can't check return FormValidation.ok(); String msg = validateAntFileMask(value, VALIDATE_ANT_FILE_MASK_BOUND, caseSensitive); if(errorIfNotExist) return FormValidation.error(msg); else return FormValidation.warning(msg); } catch (InterruptedException e) { return FormValidation.ok(Messages.FilePath_did_not_manage_to_validate_may_be_too_sl(value)); } }
String site = updatesite.getMetadataUrlForDownloadable(url); if (site == null) { return FormValidation.warning("The update site " + site + " does not look like an update center"); return FormValidation.warning("None of the tool installer metadata passed the signature check"); } else if (!toolInstallerMetadataExists) { LOGGER.log(Level.WARNING, "No tool installer metadata found for " + id);
Messages.FilePath_validateRelativePath_noSuchDirectory(value); if(errorIfNotExist) return FormValidation.error(msg); else return FormValidation.warning(msg); } catch (InterruptedException e) { return FormValidation.ok();
/** * Called by {@link #doConfirmRename} and {@code rename.jelly} to validate renames. * @return {@link FormValidation#ok} if this item can be renamed as specified, otherwise * {@link FormValidation#error} with a message explaining the problem. */ @Restricted(NoExternalUse.class) public @Nonnull FormValidation doCheckNewName(@QueryParameter String newName) { // TODO: Create an Item.RENAME permission to use here, see JENKINS-18649. if (!hasPermission(Item.CONFIGURE)) { if (parent instanceof AccessControlled) { ((AccessControlled)parent).checkPermission(Item.CREATE); } checkPermission(Item.DELETE); } newName = newName == null ? null : newName.trim(); try { Jenkins.checkGoodName(newName); assert newName != null; // Would have thrown Failure if (newName.equals(name)) { return FormValidation.warning(Messages.AbstractItem_NewNameUnchanged()); } Jenkins.get().getProjectNamingStrategy().checkName(newName); checkIfNameIsUsed(newName); checkRename(newName); } catch (Failure e) { return FormValidation.error(e.getMessage()); } return FormValidation.ok(); }
public FormValidation doCheckLabels(@AncestorInPath final Job<?, ?> project, @QueryParameter final String value) { if (!project.hasPermission(Item.CONFIGURE) || containsNoLabel(value)) { return FormValidation.ok(); } try { return checkMatchingLabels(value, getProjectLabels(project)); } catch (GitLabProjectBranchesService.BranchLoadingException e) { return FormValidation.warning(project.hasPermission(Jenkins.ADMINISTER) ? e : null, Messages.GitLabPushTrigger_CannotCheckBranches()); } }
public FormValidation doCheckBranchesSpec(@AncestorInPath final Job<?, ?> project, @QueryParameter final String value) { if (!project.hasPermission(Item.CONFIGURE) || containsNoBranches(value)) { return FormValidation.ok(); } try { return checkMatchingBranches(value, getProjectBranches(project)); } catch (GitLabProjectBranchesService.BranchLoadingException e) { return FormValidation.warning(project.hasPermission(Jenkins.ADMINISTER) ? e : null, Messages.GitLabPushTrigger_CannotCheckBranches()); } }