コード例 #1
0
ファイル: GitStep.java プロジェクト: pascalw/workflow-plugin
    public FormValidation doCheckUrl(
        @AncestorInPath Item project,
        @QueryParameter String credentialsId,
        @QueryParameter String value)
        throws IOException, InterruptedException {

      if (project == null || !project.hasPermission(Item.CONFIGURE)) {
        return FormValidation.ok();
      }

      String url = Util.fixEmptyAndTrim(value);
      if (url == null) return FormValidation.error("Please enter repository url.");

      // get git executable on master
      final EnvVars environment = new EnvVars(EnvVars.masterEnvVars);

      GitClient git =
          Git.with(TaskListener.NULL, environment)
              .using(GitTool.getDefaultInstallation().getGitExe())
              .getClient();
      if (credentialsId != null) {
        StandardCredentials credentials = lookupCredentials(project, credentialsId, url);
        if (credentials != null) git.addDefaultCredentials(credentials);
      }

      // attempt to connect the provided URL
      try {
        git.getHeadRev(url, "HEAD");
      } catch (GitException e) {
        return FormValidation.error(Messages.UserRemoteConfig_FailedToConnect(e.getMessage()));
      }

      return FormValidation.ok();
    }
 /**
  * Check method to validate the authentication details
  *
  * @param request the {@link StaplerRequest}
  * @return the {@link FormValidation} result
  * @throws IOException in case of IO exceptions
  */
 public FormValidation doLoginCheck(StaplerRequest request) throws IOException {
   String url = Util.fixEmpty(request.getParameter("url"));
   if (url == null) {
     return FormValidation.ok();
   }
   JIRASite site =
       new JIRASite(
           "Login Check",
           new URL(url),
           request.getParameter("user"),
           request.getParameter("pass"),
           false,
           null,
           false);
   try {
     site.createClient();
     return FormValidation.ok();
   } catch (RemoteAuthenticationException e) {
     return FormValidation.error(e.getMessage());
   } catch (AxisFault e) {
     return FormValidation.error(e.getFaultString());
   } catch (ServiceException e) {
     return FormValidation.error(e.getMessage());
   }
 }
コード例 #3
0
    /**
     * For test Server Address if it available
     *
     * @param value String from Server Address form
     * @return OK if ping, ERROR otherwise
     */
    public FormValidation doCheckServerAddress(@QueryParameter String value) {

      try {

        if (value == null || value.matches("\\s*")) {
          return FormValidation.warning("Set Address");
        }

        if (value.startsWith("$")) {
          return FormValidation.ok();
        }

        new Socket(value, 22).close();

      } catch (UnknownHostException e) {
        return FormValidation.error("Unknown Host\t" + value + "\t" + e.getLocalizedMessage());
      } catch (IOException e) {
        return FormValidation.error(
            "Input Output Exception while connecting to \t"
                + value
                + "\t"
                + e.getLocalizedMessage());
      }
      return FormValidation.ok();
    }
コード例 #4
0
    /** Performs on-the-fly validation of the URL. */
    public FormValidation doCheckUrl(@QueryParameter(fixEmpty = true) String value)
        throws IOException, ServletException {
      if (value == null) // nothing entered yet
      return FormValidation.ok();

      if (!value.endsWith("/")) value += '/';
      if (!URL_PATTERN.matcher(value).matches())
        return FormValidation.errorWithMarkup(
            "The URL should end like <tt>.../browse/foobar/</tt>");

      // Connect to URL and check content only if we have admin permission
      if (!Hudson.getInstance().hasPermission(Hudson.ADMINISTER)) return FormValidation.ok();

      final String finalValue = value;
      return new URLCheck() {
        @Override
        protected FormValidation check() throws IOException, ServletException {
          try {
            if (findText(open(new URL(finalValue)), "FishEye")) {
              return FormValidation.ok();
            }
            return FormValidation.error("This is a valid URL but it doesn't look like FishEye");
          } catch (IOException e) {
            return handleIOException(finalValue, e);
          }
        }
      }.check();
    }
    public FormValidation doCheckWorkflowName(
        @QueryParameter final String serverUrl,
        @QueryParameter final String userName,
        @QueryParameter final String password,
        @QueryParameter final String tenant,
        @QueryParameter final String workflowName)
        throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, IOException,
            URISyntaxException {

      String workflowNameValue = Util.fixEmptyAndTrim(workflowName);
      if (workflowNameValue == null) {
        return FormValidation.error("Please enter workflow name.");
      }

      if (workflowNameValue.indexOf('$') >= 0) {
        // set by variable, can't validate
        return FormValidation.ok();
      }
      // Call server and validate
      BuildParam buildParam = new BuildParam(serverUrl, userName, password, tenant, null);
      OrchestratorClient client = new OrchestratorClient(buildParam);
      List<Workflow> workflows = client.fetchWorkflows();

      boolean isWorkflowFound = false;
      for (Workflow workflow : workflows) {
        if (workflow.getName().equals(workflowName)) {
          isWorkflowFound = true;
        }
      }
      if (!isWorkflowFound) {
        return FormValidation.error("Workflow with the given name doesn't exist in the server.");
      }
      return FormValidation.ok();
    }
コード例 #6
0
    /** Form validation method. */
    @SuppressWarnings("rawtypes")
    public FormValidation doCheckSourceProject(
        @AncestorInPath AccessControlled subject, @QueryParameter String value) {
      // Require CONFIGURE permission on this project
      if (!subject.hasPermission(Item.CONFIGURE)) return FormValidation.ok();

      if (value == null) return FormValidation.ok();

      value = value.trim();

      if (value.equals("")) {
        return FormValidation.error("This field is required");
      }

      Item item = Hudson.getInstance().getItem(value);
      if (item == null)
        return FormValidation.error(
            "No such project '"
                + value
                + "'. Did you mean '"
                + AbstractProject.findNearest(value).getName()
                + "' ?");
      if (item instanceof Job && (((AbstractProject) item).getScm() instanceof GitSCM)) {
        return FormValidation.ok();
      }

      return FormValidation.error("'" + value + "' is not a Git project");
    }
コード例 #7
0
  /**
   * @param res
   * @param rsp
   * @param regex
   * @return FormValidation.Kind.OK if the regex is valid, FormValidation.Kind.WARNING if the regex
   *     is valid but consists only of whitespaces or has leading and/or trailing whitespaces, and
   *     FormValidation.Kind.ERROR if the regex syntax is invalid.
   */
  public FormValidation doCheckExcludedFilesRegex(
      final StaplerRequest res,
      final StaplerResponse rsp,
      @QueryParameter("value") final String regex) {

    if ((regex == null) || (regex.isEmpty())) {
      return FormValidation.ok();
    }

    try {
      Pattern.compile(regex);
    } catch (final PatternSyntaxException pse) {
      return FormValidation.error("Regex syntax is invalid.");
    }

    if (regex.trim().isEmpty()) {
      return FormValidation.warning(
          "Regex is valid, but consists entirely of whitespaces - is this intentional?");
    }

    if (!regex.trim().equals(regex)) {
      return FormValidation.warning(
          "Regex is valid, but contains leading and/or trailing whitespaces - is this intentional?");
    }

    return FormValidation.ok();
  }
コード例 #8
0
    public FormValidation doServerCheck(
        @QueryParameter final String server,
        @QueryParameter final String managerDN,
        @QueryParameter final String managerPassword) {

      if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) return FormValidation.ok();

      try {
        Hashtable<String, String> props = new Hashtable<String, String>();
        if (managerDN != null && managerDN.trim().length() > 0 && !"undefined".equals(managerDN)) {
          props.put(Context.SECURITY_PRINCIPAL, managerDN);
        }
        if (managerPassword != null
            && managerPassword.trim().length() > 0
            && !"undefined".equals(managerPassword)) {
          props.put(Context.SECURITY_CREDENTIALS, managerPassword);
        }

        props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        props.put(Context.PROVIDER_URL, toProviderUrl(server, ""));

        DirContext ctx = new InitialDirContext(props);
        ctx.getAttributes("");
        return FormValidation.ok(); // connected
      } catch (NamingException e) {
        // trouble-shoot
        Matcher m =
            Pattern.compile(
                    "(ldaps?://)?([^:]+)(?:\\:(\\d+))?(\\s+(ldaps?://)?([^:]+)(?:\\:(\\d+))?)*")
                .matcher(server.trim());
        if (!m.matches())
          return FormValidation.error(
              hudson.security.Messages.LDAPSecurityRealm_SyntaxOfServerField());

        try {
          InetAddress adrs = InetAddress.getByName(m.group(2));
          int port = m.group(1) != null ? 636 : 389;
          if (m.group(3) != null) port = Integer.parseInt(m.group(3));
          Socket s = new Socket(adrs, port);
          s.close();
        } catch (UnknownHostException x) {
          return FormValidation.error(
              hudson.security.Messages.LDAPSecurityRealm_UnknownHost(x.getMessage()));
        } catch (IOException x) {
          return FormValidation.error(
              x,
              hudson.security.Messages.LDAPSecurityRealm_UnableToConnect(server, x.getMessage()));
        }

        // otherwise we don't know what caused it, so fall back to the general error report
        // getMessage() alone doesn't offer enough
        return FormValidation.error(
            e, hudson.security.Messages.LDAPSecurityRealm_UnableToConnect(server, e));
      } catch (NumberFormatException x) {
        // The getLdapCtxInstance method throws this if it fails to parse the port number
        return FormValidation.error(hudson.security.Messages.LDAPSecurityRealm_InvalidPortNumber());
      }
    }
コード例 #9
0
 public FormValidation doCheckLaunchTimeoutStr(@QueryParameter String value) {
   if (value == null || value.trim().isEmpty()) return FormValidation.ok();
   try {
     int val = Integer.parseInt(value);
     if (val >= 0) return FormValidation.ok();
   } catch (NumberFormatException nfe) {
   }
   return FormValidation.error("Launch Timeout must be a non-negative integer (or null)");
 }
コード例 #10
0
 public FormValidation doCheckIdleTerminationMinutes(@QueryParameter String value) {
   if (value == null || value.trim().isEmpty()) return FormValidation.ok();
   try {
     int val = Integer.parseInt(value);
     if (val >= -59) return FormValidation.ok();
   } catch (NumberFormatException nfe) {
   }
   return FormValidation.error("Idle Termination time must be a greater than -59 (or null)");
 }
コード例 #11
0
  /**
   * Check if the given string points to a file on local machine. If it's not the case, just display
   * an info message, not a warning because it might be executed on a remote host.
   */
  public static FormValidation validateFileExists(
      String file,
      final String extension,
      final boolean checkExtension,
      final boolean checkInPath) {
    // If file is null or empty, return an error
    final FormValidation emptyOrNullValidation = FormValidation.validateRequired(file);
    if (!FormValidation.Kind.OK.equals(emptyOrNullValidation.kind)) {
      return emptyOrNullValidation;
    }

    if (checkExtension && !file.toLowerCase().endsWith(extension)) {
      return FormValidation.error("Please specify a file with " + extension + " extension");
    }

    // insufficient permission to perform validation?
    if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
      return FormValidation.ok("Insufficient permission to perform path validation.");
    }

    if (file.indexOf(File.separatorChar) >= 0) {
      // this is full path
      File f = new File(file);
      if (f.exists()) return FileValidator.NOOP.validate(f);

      File fexe = new File(file + extension);
      if (fexe.exists()) return FileValidator.NOOP.validate(fexe);
    }

    if (Files.exists(Paths.get(file))) {
      return FormValidation.ok();
    }

    if (checkInPath) {
      String path = EnvVars.masterEnvVars.get("PATH");

      String delimiter = null;
      if (path != null) {
        for (String _dir : Util.tokenize(path.replace("\\", "\\\\"), File.pathSeparator)) {
          if (delimiter == null) {
            delimiter = ", ";
          }
          File dir = new File(_dir);

          File f = new File(dir, file);
          if (f.exists()) return FileValidator.NOOP.validate(f);

          File fexe = new File(dir, file + ".exe");
          if (fexe.exists()) return FileValidator.NOOP.validate(fexe);
        }
      }
    }

    return FormValidation.ok(
        "There is no such file on local host. You can ignore this message if the job is executed on a remote slave.");
  }
コード例 #12
0
    public static FormValidation checkValidResponseCodes(String value) {
      if (value == null || value.trim().isEmpty()) {
        return FormValidation.ok();
      }

      try {
        parseToRange(value);
      } catch (IllegalArgumentException iae) {
        return FormValidation.error("Response codes expected is wrong. " + iae.getMessage());
      }
      return FormValidation.ok();
    }
コード例 #13
0
    public FormValidation doCheck(@QueryParameter final String value)
        throws IOException, ServletException {

      String url = Util.fixEmpty(value);
      if (url == null) {
        return FormValidation.ok();
      }
      if (!url.startsWith("http://") && !url.startsWith("https://")) {
        return FormValidation.errorWithMarkup(
            "The URL should contain <tt>http://</tt> or <tt>https://</tt>");
      }
      return FormValidation.ok();
    }
コード例 #14
0
  public FormValidation doCheckForceQuietModeTimeout(
      final StaplerRequest res,
      final StaplerResponse rsp,
      @QueryParameter("value") final String timeout) {
    FormValidation validation = FormValidation.validateNonNegativeInteger(timeout);
    if (!FormValidation.ok().equals(validation)) return validation;

    int intTimeout = Integer.parseInt(timeout);
    if (intTimeout > 12 * 60)
      return FormValidation.warning(
          "You choose a very long timeout. The value need to be in minutes.");
    else return FormValidation.ok();
  }
    public FormValidation doCheckUserName(@QueryParameter final String value) {

      String username = Util.fixEmptyAndTrim(value);
      if (username == null) {
        return FormValidation.error("Please enter user name.");
      }

      if (username.indexOf('$') >= 0) {
        // set by variable, can't validate
        return FormValidation.ok();
      }

      return FormValidation.ok();
    }
コード例 #16
0
      /** Checks if the sbt-launch.jar is exist. */
      public FormValidation doCheckHome(@QueryParameter File value) {

        if (!Jenkins.getInstance().hasPermission(Jenkins.ADMINISTER)) {
          return FormValidation.ok();
        }

        // allow empty input
        if (value.getPath().equals("")) return FormValidation.ok();

        if (!value.exists() || !value.isFile()) {
          return FormValidation.error("sbt-launch.jar not found");
        }

        return FormValidation.ok();
      }
コード例 #17
0
    public FormValidation doCheck(
        @AncestorInPath AbstractProject project, @QueryParameter String value) {
      // Require CONFIGURE permission on this project
      if (!project.hasPermission(Item.CONFIGURE)) return FormValidation.ok();

      for (String name : Util.tokenize(fixNull(value), ",")) {
        name = name.trim();
        if (Jenkins.getInstance().getItem(name, project) == null)
          return FormValidation.error(
              hudson.tasks.Messages.BuildTrigger_NoSuchProject(
                  name, AbstractProject.findNearest(name).getName()));
      }

      return FormValidation.ok();
    }
コード例 #18
0
ファイル: EC2Cloud.java プロジェクト: ryanaslett/ec2-plugin
    protected FormValidation doTestConnection(
        URL ec2endpoint,
        boolean useInstanceProfileForCredentials,
        String accessId,
        String secretKey,
        String privateKey)
        throws IOException, ServletException {
      try {
        AWSCredentialsProvider credentialsProvider =
            createCredentialsProvider(useInstanceProfileForCredentials, accessId, secretKey);
        AmazonEC2 ec2 = connect(credentialsProvider, ec2endpoint);
        ec2.describeInstances();

        if (privateKey == null)
          return FormValidation.error(
              "Private key is not specified. Click 'Generate Key' to generate one.");

        if (privateKey.trim().length() > 0) {
          // check if this key exists
          EC2PrivateKey pk = new EC2PrivateKey(privateKey);
          if (pk.find(ec2) == null)
            return FormValidation.error(
                "The EC2 key pair private key isn't registered to this EC2 region (fingerprint is "
                    + pk.getFingerprint()
                    + ")");
        }

        return FormValidation.ok(Messages.EC2Cloud_Success());
      } catch (AmazonClientException e) {
        LOGGER.log(Level.WARNING, "Failed to check EC2 credential", e);
        return FormValidation.error(e.getMessage());
      }
    }
コード例 #19
0
    public FormValidation doCheckMemorySize(@QueryParameter String value)
        throws IOException, ServletException {

      if (value.length() == 0)
        return FormValidation.error(Messages.validation_required("Memory Size"));
      return FormValidation.ok();
    }
コード例 #20
0
 public FormValidation doValidate(
     @QueryParameter String username,
     @QueryParameter String apiKey,
     @QueryParameter boolean disableStatusColumn,
     @QueryParameter boolean reuseSauceAuth) {
   try {
     SauceOnDemandAuthentication credential =
         reuseSauceAuth
             ? new SauceOnDemandAuthentication()
             : new SauceOnDemandAuthentication(
                 username, Secret.toString(Secret.fromString(apiKey)));
     // we aren't interested in the results of the REST API call - just the fact that we executed
     // without an error is enough to verify the connection
     if (reuseSauceAuth
         && StringUtils.isBlank(credential.getUsername())
         && StringUtils.isBlank(credential.getAccessKey())) {
       return FormValidation.error("Unable to find ~/.sauce-ondemand file");
     } else {
       String response =
           new SauceREST(credential.getUsername(), credential.getAccessKey())
               .retrieveResults("tunnels");
       if (response != null && !response.equals("")) {
         return FormValidation.ok("Success");
       } else {
         return FormValidation.error("Failed to connect to Sauce OnDemand");
       }
     }
   } catch (Exception e) {
     return FormValidation.error(e, "Failed to connect to Sauce OnDemand");
   }
 }
コード例 #21
0
 /*
  * --- Validation methods ---
  */
 public FormValidation doCheckMandatory(@QueryParameter String value) {
   FormValidation returnValue = FormValidation.ok();
   if (StringUtils.isBlank(value)) {
     returnValue = FormValidation.error("Required value.");
   }
   return returnValue;
 }
    // Form validation
    @SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unused"})
    public FormValidation doTestConnection(
        @QueryParameter(CLIENT_ID) final String clientId,
        @QueryParameter(CLIENT_SECRET) final String clientSecret,
        @QueryParameter(BASE_URL) final String baseUrl) {
      if (clientId == null || clientId.isEmpty()) return FormValidation.error("API Key is empty!");
      if (clientSecret == null || clientSecret.isEmpty())
        return FormValidation.error("Secret Key is empty!");
      if (baseUrl == null || baseUrl.isEmpty())
        return FormValidation.error("Fortify on Demand URL is empty!");

      FodApi testApi = new FodApi(clientId, clientSecret, baseUrl);

      testApi.authenticate();
      String token = testApi.getToken();

      if (token == null) {
        return FormValidation.error("Unable to retrieve authentication token.");
      }

      return !token.isEmpty()
          ? FormValidation.ok("Successfully authenticated to Fortify on Demand.")
          : FormValidation.error(
              "Invalid connection information. Please check your credentials and try again.");
    }
コード例 #23
0
 public FormValidation doCheckReposUrl(@QueryParameter String value) {
   FormValidation result;
   final Matcher matcher = URL_PATTERN.matcher(value);
   if (matcher.matches()) {
     try {
       final URL repUrl = new URL(matcher.group(URL_PATTERN_BASE_URL_GROUP));
       final String repName = matcher.group(URL_PATTERN_REPNAME_GROUP);
       if (repName == null || "".equals(repName)) { // Go online??
         result =
             FormValidation.okWithMarkup(
                 "Please set a url including the repname property if needed.");
       } else {
         result = FormValidation.ok();
       }
     } catch (MalformedURLException ex) {
       result =
           FormValidation.error("The entered url is not accepted: " + ex.getLocalizedMessage());
     }
   } else if ("".equals(value)) {
     result =
         FormValidation.okWithMarkup(
             "Please set a WebSVN url in the form "
                 + "https://<i>server</i>/websvn/listing.php?repname=<i>rep</i>&path=/trunk/..");
   } else {
     result = FormValidation.error("Please set a url including the WebSVN php script.");
   }
   return result;
 }
コード例 #24
0
ファイル: HygieiaPublisher.java プロジェクト: azat-co/Hygieia
    public FormValidation doTestConnection(
        @QueryParameter("hygieiaAPIUrl") final String hygieiaAPIUrl,
        @QueryParameter("hygieiaToken") final String hygieiaToken,
        @QueryParameter("hygieiaJenkinsName") final String hygieiaJenkinsName,
        @QueryParameter("useProxy") final String sUseProxy)
        throws FormException {

      String hostUrl = hygieiaAPIUrl;
      if (StringUtils.isEmpty(hostUrl)) {
        hostUrl = this.hygieiaAPIUrl;
      }
      String targetToken = hygieiaToken;
      if (StringUtils.isEmpty(targetToken)) {
        targetToken = this.hygieiaToken;
      }
      String name = hygieiaJenkinsName;
      if (StringUtils.isEmpty(name)) {
        name = this.hygieiaJenkinsName;
      }
      boolean bProxy = "true".equalsIgnoreCase(sUseProxy);
      if (StringUtils.isEmpty(sUseProxy)) {
        bProxy = this.useProxy;
      }
      HygieiaService testHygieiaService = getHygieiaService(hostUrl, targetToken, name, bProxy);
      if (testHygieiaService != null) {
        boolean success = testHygieiaService.testConnection();
        return success ? FormValidation.ok("Success") : FormValidation.error("Failure");
      } else {
        return FormValidation.error("Failure");
      }
    }
コード例 #25
0
ファイル: HygieiaPublisher.java プロジェクト: azat-co/Hygieia
 public FormValidation doCheckValue(@QueryParameter String value)
     throws IOException, ServletException {
   if (value.isEmpty()) {
     return FormValidation.warning("You must fill this box!");
   }
   return FormValidation.ok();
 }
    /**
     * Check method to validate the URL given
     *
     * @param value the URL to check
     * @return the {@link FormValidation} results
     * @throws IOException in case of IO exceptions
     * @throws ServletException
     */
    public FormValidation doUrlCheck(@QueryParameter final String value)
        throws IOException, ServletException {
      if (!Hudson.getInstance().hasPermission(Hudson.ADMINISTER)) {
        return FormValidation.ok();
      }
      return new FormValidation.URLCheck() {

        @Override
        protected FormValidation check() throws IOException, ServletException {
          String url = Util.fixEmpty(value);
          if (url == null) {
            return FormValidation.error("The URL parameter is required");
          } else if (!url.endsWith("/")) {
            url = url + "/";
          }
          try {
            if (!findText(open(new URL(url)), "Atlassian JIRA")) {
              return FormValidation.error("This URL does not point to an Atlassian JIRA instance");
            }
            URL soapUrl = new URL(new URL(url), JIRASite.SERVICE_ENDPOINT_WSDL);
            if (!findText(open(soapUrl), "wsdl:definitions")) {
              return FormValidation.error("Unable to access the JIRA SOAP service. Is it enabled?");
            }
            return FormValidation.ok();
          } catch (IOException e) {
            return handleIOException(url, e);
          }
        }
      }.check();
    }
コード例 #27
0
 /** Performs on-the-fly validation on the file mask wildcard. */
 public FormValidation doCheckTestResults(
     @AncestorInPath AbstractProject project, @QueryParameter String value) throws IOException {
   if (project == null) {
     return FormValidation.ok();
   }
   return FilePath.validateFileMask(project.getSomeWorkspace(), value);
 }
コード例 #28
0
 public static FormValidation validateWarnIfEmpty(
     final String fieldValue, final String displayName) {
   if (StringUtils.trimToNull(fieldValue) == null) {
     return FormValidation.warning("Don't forget to include the " + displayName + ".");
   }
   return FormValidation.ok();
 }
コード例 #29
0
 public FormValidation doTestConnection(
     @QueryParameter("slackTeamDomain") final String teamDomain,
     @QueryParameter("slackToken") final String authToken,
     @QueryParameter("slackRoom") final String room,
     @QueryParameter("slackBuildServerUrl") final String buildServerUrl)
     throws FormException {
   try {
     String targetDomain = teamDomain;
     if (StringUtils.isEmpty(targetDomain)) {
       targetDomain = this.teamDomain;
     }
     String targetToken = authToken;
     if (StringUtils.isEmpty(targetToken)) {
       targetToken = this.token;
     }
     String targetRoom = room;
     if (StringUtils.isEmpty(targetRoom)) {
       targetRoom = this.room;
     }
     String targetBuildServerUrl = buildServerUrl;
     if (StringUtils.isEmpty(targetBuildServerUrl)) {
       targetBuildServerUrl = this.buildServerUrl;
     }
     SlackService testSlackService = getSlackService(targetDomain, targetToken, targetRoom);
     String message = "Slack/Jenkins plugin: you're all set on " + targetBuildServerUrl;
     boolean success = testSlackService.publish(message, "good");
     return success ? FormValidation.ok("Success") : FormValidation.error("Failure");
   } catch (Exception e) {
     return FormValidation.error("Client error : " + e.getMessage());
   }
 }
コード例 #30
0
    public FormValidation doCheckWorkflowActionName(@QueryParameter String value) {
      if (Util.fixNull(value).trim().length() == 0) {
        return FormValidation.warning(Messages.JiraIssueUpdateBuilder_NoWorkflowAction());
      }

      return FormValidation.ok();
    }