Class Common
java.lang.Object
org.thoughtslive.jenkins.plugins.hubot.util.Common
Common utility functions.
- Author:
- Naresh Rayapati
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> ResponseData<T> Builds error response from the given exception.static MapexpandMacros(String tokens, Run<?, ?> run, FilePath ws, TaskListener listener) Expands given macro, see Token Marco plugin.static StringgetBuildNumber(PrintStream logger, EnvVars envVars) Returns build number from the given Environment Vars.static StringgetJobName(EnvVars envVars) static ThrowablegetRootCause(Throwable throwable) Returns actual Cause from the given exception.static voidlog(PrintStream logger, Object message) Write a message to the given print stream.static <T> ResponseData<T> logResponse(ResponseData<T> response, PrintStream logger, boolean failOnError) Log code and error message if any.static <T> ResponseData<T> parseResponse(retrofit2.Response<T> response) Converts Retrofit'sResponsetoResponseDatastatic StringprepareBuildCause(List<Cause> causes) Retrun the build cause.static StringprepareBuildUserId(List<Cause> causes, EnvVars envVars) Return the current build user Id.static StringprepareBuildUserName(List<Cause> causes, EnvVars envVars) Return the current build user.static StringsanitizeURL(String url) Attaches the "/" at end of given url.
-
Constructor Details
-
Common
public Common()
-
-
Method Details
-
sanitizeURL
Attaches the "/" at end of given url.- Parameters:
url- url as a string.- Returns:
- url which ends with "/"
-
log
Write a message to the given print stream.- Parameters:
logger-PrintStreammessage- to log.
-
getJobName
-
getBuildNumber
Returns build number from the given Environment Vars.- Parameters:
logger-PrintStreamenvVars-EnvVars- Returns:
- build number of current job.
-
parseResponse
Converts Retrofit'sResponsetoResponseData- Parameters:
response- instance ofResponse- Returns:
- an instance of
ResponseData - Throws:
IOException
-
buildErrorResponse
Builds error response from the given exception.- Parameters:
e- instance ofException- Returns:
- an instance of
ResponseData
-
getRootCause
Returns actual Cause from the given exception.- Returns:
Throwable
-
prepareBuildUserName
Return the current build user.- Parameters:
causes- build causes.envVars- environment variables.- Returns:
- user name.
-
prepareBuildCause
Retrun the build cause.- Returns:
- build cause.
-
prepareBuildUserId
Return the current build user Id.- Parameters:
causes- build causes.envVars- environment variables.- Returns:
- user name.
-
expandMacros
Expands given macro, see Token Marco plugin. -
logResponse
public static <T> ResponseData<T> logResponse(ResponseData<T> response, PrintStream logger, boolean failOnError) throws AbortException Log code and error message if any.- Returns:
- response data.
- Throws:
AbortException
-