Class Utils
java.lang.Object
org.jenkinsci.plugins.slave_setup.Utils
Static methods class container used across the code.
- Author:
- ByteHeed:, Mikel Royo Gutierrez, Aaron Giovannini
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets 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/511b19f24d6a59902c6d6b6c838c7c8a85674d85static 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 separatorstatic String
osLineSeparator
(String someFullPath) Given full path from OS, returns os End of line separatorstatic 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
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
osLineSeparator
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
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 channelscript
- String pure script content to be executed in Abstracted OSroot
- FilePath (Jenkins) from Computer to be executedenviroment
- EnvVars, not necesary, but will be included in Computer before be executed- Returns:
- int containing returnCode
- Throws:
IOException
- if failed to read/write some fileInterruptedException
- User request Disconnect/Cancel
-
labelMatches
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 reggexslave
- Computer where will check if pattern matchs- Returns:
- boolean true if pattern matches with slave labels
-
stringFy
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
Gets all active (ONLINE) slaves running on the all jenkins instance.- Returns:
- List of Computer containing the current active slaves.
-