public static FormValidation ok(String message) { return okWithMarkup(message==null?null:Util.escape(message)); }
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()); } }
return FormValidation.okWithMarkup(Messages.AbstractProject_LabelLink( j.getRootUrl(), Util.escape(l.getName()), l.getUrl(), l.getNodes().size(), l.getClouds().size()) );
public FormValidation doCheckNumberOfMates( @QueryParameter("firstClass") String firstClass, @QueryParameter("secondClass") String secondClass) { int numOfMates = ProjectCreationEngine.instance.getNumOfMates( firstClass, secondClass ); String msg = "Will generate " + numOfMates + " mated projects"; if (numOfMates > 0) { return FormValidation.okWithMarkup(msg); } else { return FormValidation.error(msg); } }
public FormValidation doCheckNumberOfMates( @QueryParameter("firstClass") String firstClass, @QueryParameter("secondClass") String secondClass) { int numOfMates = ProjectCreationEngine.instance.getNumOfMates( firstClass, secondClass ); String msg = "Will generate " + numOfMates + " mated projects"; if (numOfMates > 0) { return FormValidation.okWithMarkup(msg); } else { return FormValidation.error(msg); } }
public static FormValidation ok(String message) { return okWithMarkup(message==null?null:Util.escape(message)); }
public static FormValidation ok(String message) { return okWithMarkup(message==null?null:Util.escape(message)); }
public static FormValidation ok(String message) { return okWithMarkup(message == null ? null : Util.escape(message)); } /**
public static FormValidation ok(String message) { return okWithMarkup(message==null?null:Util.escape(message)); }
public static FormValidation ok(String message) { return okWithMarkup(message==null?null:Util.escape(message)); }
public FormValidation doTestConnection(@QueryParameter("host") String host, @QueryParameter("port") int port, @QueryParameter("password") Secret password, @QueryParameter("username") String username, @QueryParameter("database") String database, @QueryParameter("collection") String collection) { String res = ""; try { res = new MongoDBHolderService(username, password, port, host, database).testConnection(collection); } catch (CompatibilityDataException ex) { return FormValidation.error(ex.getMessage()); } catch (Exception unknown) { return FormValidation.error(unknown.getMessage()); } String msg = !StringUtils.isBlank(res) ? res : ""; return FormValidation.okWithMarkup("Connection established. Listing a random element." + msg); } }
public FormValidation doValidateUpload(@QueryParameter("applicationName") String applicationName, @QueryParameter("bucketName") String bucketName, @QueryParameter("keyPrefix") String keyPrefix, @QueryParameter("versionLabelFormat") String versionLabelFormat) { String objectKey = Utils.formatPath("%s/%s-%s.zip", defaultIfBlank(keyPrefix, "<ERROR: MISSING KEY PREFIX>"), defaultIfBlank(applicationName, "<ERROR: MISSING APPLICATION NAME>"), defaultIfBlank(versionLabelFormat, "<ERROR: MISSING VERSION LABEL FORMAT>")); String targetPath = String.format("s3://%s/%s", defaultIfBlank(bucketName, "[default account bucket for region]"), objectKey); final String resultingMessage = format("Your object will be uploaded to S3 as: <code>%s</code> (<i>note replacements will apply</i>)", targetPath); return FormValidation.okWithMarkup(resultingMessage); } }
/** * Called by validation button in UI when triggering a job manually * @param label the label to search the nodes for * @return if ok, a list of nodes matching the given label * @throws ServletException */ public FormValidation doListNodesForLabel(@QueryParameter("label") final String label) throws ServletException { if (StringUtils.isBlank(label)) return FormValidation.error(Messages.LabelParameterDefinition_labelRequired()); try { final Set<Node> nodes = getNodesForLabel(label); if(nodes.isEmpty()) { return FormValidation.warning(Messages.NodeLabelParameterDefinition_noNodeMatched(label)); } final Collection<String> nodeNames = Collections2.transform(nodes, new NodeDescFunction()); final String html = Joiner.on("</li><li>").join(nodeNames); return FormValidation.okWithMarkup("<b>"+Messages.LabelParameterDefinition_matchingNodes()+"</b><ul><li>" + html +"</li></ul>"); } catch (ANTLRException e) { return FormValidation.error(Messages.NodeLabelParameterDefinition_labelExpressionNotValid(label, e.getMessage())); } }
public FormValidation doTestConnection(@AncestorInPath ItemGroup context, @QueryParameter("credentialsId") final String credentialsId) { String environment = "prod"; String targetAPI = chooseTargetAPI(environment); String iamAPI = chooseIAMAPI(environment); try { StandardCredentials credentials = findCredentials(credentialsId, context); getTokenForFreeStyleJob(credentials, iamAPI, targetAPI, null); return FormValidation.okWithMarkup(getMessage(TEST_CONNECTION_SUCCEED)); } catch (Exception e) { e.printStackTrace(); return FormValidation.error(getMessage(LOGIN_IN_FAIL)); } }
public FormValidation doTestConnection(@AncestorInPath ItemGroup context, @QueryParameter("credentialsId") final String credentialsId) { String environment = "prod"; String targetAPI = chooseTargetAPI(environment); String iamAPI = chooseIAMAPI(environment); try { StandardCredentials credentials = findCredentials(credentialsId, context); getTokenForFreeStyleJob(credentials, iamAPI, targetAPI, null); return FormValidation.okWithMarkup(getMessage(TEST_CONNECTION_SUCCEED)); } catch (Exception e) { e.printStackTrace(); return FormValidation.error(getMessage(LOGIN_IN_FAIL)); } }
public FormValidation doTestConnection(@AncestorInPath ItemGroup context, @QueryParameter("credentialsId") final String credentialsId) { String environment = "prod"; String targetAPI = chooseTargetAPI(environment); String iamAPI = chooseIAMAPI(environment); try { StandardCredentials credentials = findCredentials(credentialsId, context); getTokenForFreeStyleJob(credentials, iamAPI, targetAPI, null); return FormValidation.okWithMarkup(getMessage(TEST_CONNECTION_SUCCEED)); } catch (Exception e) { e.printStackTrace(); return FormValidation.error(getMessage(LOGIN_IN_FAIL)); } }
public FormValidation doTestConnection(@AncestorInPath ItemGroup context, @QueryParameter("credentialsId") final String credentialsId) { String environment = "prod"; String targetAPI = chooseTargetAPI(environment); String iamAPI = chooseIAMAPI(environment); try { StandardCredentials credentials = findCredentials(credentialsId, context); getTokenForFreeStyleJob(credentials, iamAPI, targetAPI, null); return FormValidation.okWithMarkup(getMessage(TEST_CONNECTION_SUCCEED)); } catch (Exception e) { e.printStackTrace(); return FormValidation.error(getMessage(LOGIN_IN_FAIL)); } }
public FormValidation doTestConnection(@AncestorInPath ItemGroup context, @QueryParameter("credentialsId") final String credentialsId) { String environment = "prod"; String targetAPI = chooseTargetAPI(environment); String iamAPI = chooseIAMAPI(environment); try { StandardCredentials credentials = findCredentials(credentialsId, context); getTokenForFreeStyleJob(credentials, iamAPI, targetAPI, null); return FormValidation.okWithMarkup(getMessage(TEST_CONNECTION_SUCCEED)); } catch (Exception e) { e.printStackTrace(); return FormValidation.error(getMessage(LOGIN_IN_FAIL)); } }
private FormValidation getUserDataLink(String id, String name) { return FormValidation.okWithMarkup( "<a target='_blank' href='" + Jenkins.getActiveInstance().getRootUrl() + "configfiles/editConfig?id=" + Util.escape(id) + "'>" + Util.escape(name) + "</a>" ); }
@Override public FormValidation validateVersion(String name, String version) { if (!Items.XSTREAM2.toXML(scm).contains("${library." + name + ".version}")) { return FormValidation.warningWithMarkup("When using <b>" + getDescriptor().getDisplayName() + "</b>, you will need to include <code>${library." + Util.escape(name) + ".version}</code> in the SCM configuration somewhere."); } return FormValidation.okWithMarkup("Cannot validate default version with legacy SCM plugins via <b>" + getDescriptor().getDisplayName() + "</b>. Use " + Jenkins.getActiveInstance().getDescriptorByType(SCMSourceRetriever.DescriptorImpl.class).getDisplayName() + " if available."); }