Class Utils

java.lang.Object
org.jenkinsci.plugins.slave_setup.Utils

public class Utils extends Object
Static methods class container used across the code.
Author:
ByteHeed:, Mikel Royo Gutierrez, Aaron Giovannini
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static List<Computer>
    Gets all active (ONLINE) slaves running on the all jenkins instance.
    static boolean
    labelMatches(String pattern, Computer slave)
    Improved function, this will check if label matches with one of slave labels or Will match if some reggex matches with all slave labels https://github.com/beerdn/slave-setup-plugin/commit/511b19f24d6a59902c6d6b6c838c7c8a85674d85
    static int
    multiOsExecutor(TaskListener listener, String script, FilePath root, EnvVars enviroment)
    Added Unix and Win32 Platform Handling to add support to Windows OS by using the BatchFile obj letting us to configure automated WIN machines on our Integration enviroments.
    static String
    osLineSeparator(boolean isUnix)
    With given boolean for isUnix operating System, returns OS end of line separator
    static String
    osLineSeparator(String someFullPath)
    Given full path from OS, returns os End of line separator
    static String
    Idea from https://stackoverflow.com/questions/1526826/printing-all-variables-value-from-a-class This class prints entire properies, methods, from any object, Useful to debug unkown objects

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • osLineSeparator

      public static String osLineSeparator(boolean isUnix)
      With given boolean for isUnix operating System, returns OS end of line separator
      Parameters:
      isUnix - boolean, true for Unix OS
      Returns:
      String, conaining Operating System End of Line character
    • osLineSeparator

      public static String osLineSeparator(String someFullPath)
      Given full path from OS, returns os End of line separator
      Parameters:
      someFullPath - String with non relative path to any file/folder
      Returns:
      String, conaining Operating System End of Line character
    • multiOsExecutor

      public static int multiOsExecutor(TaskListener listener, String script, FilePath root, EnvVars enviroment) throws IOException, InterruptedException
      Added Unix and Win32 Platform Handling to add support to Windows OS by using the BatchFile obj letting us to configure automated WIN machines on our Integration enviroments. Observed that both Shell and BatchFile are heritages from CommandInterpreter so we added the BatchFile for WIN OSs support. This new static method replaces on SetupDeployer and SetupSlaveLauncher the execute and executeScript Shell instancing and executing respectively.
      Parameters:
      listener - TaskListener, connected to slave computer, will give us channel
      script - String pure script content to be executed in Abstracted OS
      root - FilePath (Jenkins) from Computer to be executed
      enviroment - EnvVars, not necesary, but will be included in Computer before be executed
      Returns:
      int containing returnCode
      Throws:
      IOException - if failed to read/write some file
      InterruptedException - User request Disconnect/Cancel
    • labelMatches

      public static boolean labelMatches(String pattern, Computer slave)
      Improved function, this will check if label matches with one of slave labels or Will match if some reggex matches with all slave labels https://github.com/beerdn/slave-setup-plugin/commit/511b19f24d6a59902c6d6b6c838c7c8a85674d85
      Parameters:
      pattern - String pattern containing one label or reggex
      slave - Computer where will check if pattern matchs
      Returns:
      boolean true if pattern matches with slave labels
    • stringFy

      public static String stringFy(Object obj)
      Idea from https://stackoverflow.com/questions/1526826/printing-all-variables-value-from-a-class This class prints entire properies, methods, from any object, Useful to debug unkown objects
      Parameters:
      obj - Object to get verbose content
      Returns:
      String with entire obj readed
    • getAllActiveSlaves

      public static List<Computer> getAllActiveSlaves()
      Gets all active (ONLINE) slaves running on the all jenkins instance.
      Returns:
      List of Computer containing the current active slaves.