コード例 #1
0
 /**
  * @return true if the CollabNet version is late enough (5.2+) that using this
  *     AuthorizationStrategy is effective.
  */
 public static boolean isGoodCNVersion(String url) {
   VersionNumber version = getVersion(url);
   if (version == null) {
     // we can't check, so we'll assume it's ok.
     return true;
   }
   VersionNumber desiredVersion = new VersionNumber(GOOD_VERSION);
   return version.compareTo(desiredVersion) >= 0;
 }
コード例 #2
0
 /**
  * Assess whether the dependency actually needs to be installed or upgraded.
  *
  * @param jenkins top-level jenkins object
  * @param d the dependency
  * @return true if the dependency should be installed/upgraded. Otherwise, false.
  */
 private boolean shouldBeIncluded(Jenkins jenkins, Dependency d) {
   try {
     VersionNumber installedVersion = jenkins.getPlugin(d.name).getVersion();
     VersionNumber requiredVersion = new VersionNumber(d.version);
     return installedVersion.isOlderThan(requiredVersion);
   } catch (IllegalArgumentException ex) {
     // Plugin not installed
     return true;
   }
 }
コード例 #3
0
 /**
  * Check whether the "incorrect version" msg should be displayed, and returns what the currently
  * configured version is, in a json.
  */
 public void doVersionCheck(StaplerRequest req, StaplerResponse rsp, @QueryParameter String url)
     throws IOException {
   rsp.setContentType("text/plain;charset=UTF-8");
   JSONObject versionJSON = new JSONObject();
   String error_display_style = "none";
   if (!isGoodCNVersion(url)) {
     error_display_style = "inline";
   }
   versionJSON.element("error_display_style", error_display_style);
   VersionNumber version = getVersion(url);
   if (version != null) {
     versionJSON.element("version", version.toString());
   } else {
     versionJSON.element("version", "unknown");
   }
   rsp.getWriter().print(versionJSON.toString());
 }