Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

using the mid.jar MANIFEST.MF build details to get the actual ServiceNow version?

stevemac
Tera Guru

Hi,

 

We face a challenge with instance upgrades (full and patch) and our CyberArk (CP) integrations.  The CyberArk Hash value for mid.jar changes with each version.

 

We have semi-automated the generation of the Hash value as follows:

  • Download the new version of the MID Server Agent zip file from install.service-now.com to the MID Server host (using the build date and tag information)
  • Extract the contents of the zip file into a temporary directory
  • from the instance (via a custom widget and using a custom flow / powershell), execute the Cyberark Hash utility against extracted mid.jar file
    • this will return the hash value and get the package.filename value from agent\packaage\meta\mid-core.meta.properties

I'd like to get to the stage where we only extract the mid.jar file and determine the ServiceNow version from mid.jar.   The issue is I cannot  find the "friendly" ServiceNow version from the mid.var file.  I can get the build info from the manifest file, but have no idea how to get the ServiceNow version from that

 

  • Is anyone aware how to use the MANIFEST.MF (\agent\lib\mid.jar\META-INF\) information in the JAR file to get the ServiceNow version?
  • is there anything else in mid.jar that can be used to get the version?

thanks,

 

Steve

 

5 REPLIES 5

Based on the link Tanushree posted it seems like the mid server checks its version from those two files and it intermittently pings the instanceinfo processor for the instance version. The jar just contains the compiled java for the mid server there are not many files that don't have the .class extension. So not sure what the odds are that you could just read it from here. What is the benefit of reading one file vs two? 

 

//\agent\lib\mid\com\service_now\mid\InstanceInfoQuery.class

package com.service_now.mid;

import com.glide.util.InstanceSOAPClient;
import com.glide.util.XMLUtil;
import com.service_now.mid.InstanceInfoQuery.InstanceLocalInfo.Builder;
import com.service_now.mid.services.Instances;
import com.snc.core_automation_common.logging.Logger;
import com.snc.core_automation_common.logging.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
import org.w3c.dom.Document;

public class InstanceInfoQuery {
   private static final String PURPOSE = "purpose";
   private static final Logger fLogger = LoggerFactory.getLogger(InstanceInfoQuery.class);
   private String fErrorMsg;
   private String fInstanceName;
   private String fInstanceBuildDate;
   private String fInstanceBuildTag;
   private String fInstanceReleaseCandidate;
   private String fInstanceID;
   private String fInstanceIP;
   private String fClusterNode;
   private String fInstallName;
   private String fMIDServerBuildstamp;
   private String fSystemID;

   public boolean query() {
      InstanceSOAPClient isc = new InstanceSOAPClient(Instances.get().getPrimaryInstance(), "InstanceInfo.do", false);
      Map params = new HashMap();
      Document doc = isc.request(params);
      if (isc.isError()) {
         String instanceUrl = Instances.get().getPrimaryInstance().getURL();
         this.fErrorMsg = isc.getErrorMsg();
         if (this.fErrorMsg == null) {
            this.fErrorMsg = "";
         } else {
            this.fErrorMsg = this.fErrorMsg + "\n";
         }

         this.fErrorMsg = this.fErrorMsg + "(Network Configuration issue) Please check that the MID server can ping the instance: " + instanceUrl;
         if (instanceUrl.toLowerCase().startsWith("https")) {
            this.fErrorMsg = this.fErrorMsg + "\nYou may also need to configure the network that the MID server uses to allow traffic over TCP port 443.";
         }

         return false;
      } else if (doc == null) {
         this.fErrorMsg = "No document returned from InstanceInfo invocation";
         return false;
      } else if ("access restricted".equals(this.getDatum(doc, "instance_name"))) {
         this.fErrorMsg = String.format("User: %s doesn't have the proper role while accessing instance url: %s", Instances.get().getPrimaryInstance().getUserName(), isc.getURL());
         return false;
      } else {
         try {
            this.fInstanceName = this.getDatum(doc, "instance_name");
            this.fInstanceBuildDate = this.getDatum(doc, "build_date");
            this.fInstanceBuildTag = this.getDatum(doc, "build_tag");
            this.fInstanceID = this.getDatum(doc, "instance_id");
            this.fInstanceIP = this.getDatum(doc, "instance_ip");
            this.fClusterNode = this.getDatum(doc, "node_id");
            this.fInstallName = this.getDatum(doc, "install_name");
            this.fMIDServerBuildstamp = this.getDatum(doc, "mid_buildstamp");
            this.fSystemID = this.getDatum(doc, "system_id");
            this.fInstanceReleaseCandidate = this.getDatum(doc, "release_candidate", "false");
            return true;
         } catch (IllegalArgumentException var5) {
            return false;
         }
      }
   }

   private String getDatum(Document doc, String name) throws IllegalArgumentException {
      String datum = XMLUtil.getText(doc, "//result/" + name);
      if (datum == null) {
         this.fErrorMsg = "Field " + name + " missing in InstanceInfo response";
         throw new IllegalArgumentException();
      } else {
         return datum;
      }
   }

   private String getDatum(Document doc, String name, String defaultValue) {
      String datum = XMLUtil.getText(doc, "//result/" + name);
      return datum == null ? defaultValue : datum;
   }

   public String getErrorMsg() {
      return this.fErrorMsg;
   }

   public String getInstanceName() {
      return this.fInstanceName;
   }

   public String getInstanceBuildDate() {
      return this.fInstanceBuildDate;
   }

   public String getInstanceBuildTag() {
      return this.fInstanceBuildTag;
   }

   public String getInstanceReleaseCandidate() {
      return this.fInstanceReleaseCandidate;
   }

   public String getInstanceID() {
      return this.fInstanceID;
   }

   public String getInstanceIP() {
      return this.fInstanceIP;
   }

   public String getClusterNode() {
      return this.fClusterNode;
   }

   public String getInstallName() {
      return this.fInstallName;
   }

   public String getMIDServerBuildstamp() {
      return this.fMIDServerBuildstamp;
   }

   public String getSystemID() {
      return this.fSystemID;
   }

   public com.service_now.mid.InstanceInfoQuery.InstanceLocalInfo queryLocalInfo() {
      InstanceSOAPClient isc = new InstanceSOAPClient(Instances.get().getPrimaryInstance(), "InstanceInfo.do", false);
      Map<String, String> params = new HashMap();
      params.put("purpose", "GetLocalInfo");
      Document doc = isc.request(params);
      if (!isc.isError() && doc != null) {
         Builder builder = new Builder();
         builder.timeZoneName(this.getDatum(doc, "time_zone_name", "")).language(this.getDatum(doc, "language", "")).sysDateFormat(this.getDatum(doc, "sys_date_format", "")).sysTimeFormat(this.getDatum(doc, "sys_time_format", ""));
         com.service_now.mid.InstanceInfoQuery.InstanceLocalInfo instanceLocalInfo = builder.build();
         fLogger.debug("Instance local info: %s", new Object[]{instanceLocalInfo.toString()});
         return instanceLocalInfo;
      } else {
         String instanceUrl = Instances.get().getPrimaryInstance().getURL();
         fLogger.error("Failed to query local info at %s. %s", new Object[]{instanceUrl, isc.getErrorMsg() == null ? "" : isc.getErrorMsg()});
         return null;
      }
   }