public class DatadogUtilities extends Object
Constructor and Description |
---|
DatadogUtilities() |
Modifier and Type | Method and Description |
---|---|
static void |
cleanUpTraceActions(Actionable actionable)
Removes all actions related to traces for Jenkins pipelines.
|
static Map<String,Set<String>> |
computeTagListFromVarList(EnvVars envVars,
String varList) |
static List<String> |
cstrToList(String str)
Converts a Comma Separated List into a List Object
|
static long |
currentTimeMillis() |
static String |
getAwsInstanceID() |
static Map<String,Set<String>> |
getBuildTags(Run run,
EnvVars envVars)
Builds extraTags if any are configured in the Job.
|
static String |
getCatchErrorResult(org.jenkinsci.plugins.workflow.graph.BlockStartNode startNode) |
static Map<String,Set<String>> |
getComputerTags(Computer computer) |
static DatadogGlobalConfiguration |
getDatadogGlobalDescriptor() |
static DatadogJobProperty |
getDatadogJobProperties(Run r) |
static org.jenkinsci.plugins.workflow.graph.BlockStartNode |
getEnclosingStageNode(org.jenkinsci.plugins.workflow.graph.FlowNode node)
Returns enclosing stage node for the given node.
|
static Throwable |
getErrorObj(org.jenkinsci.plugins.workflow.graph.FlowNode flowNode)
Returns the
Throwable of a certain FlowNode , if it has errors. |
static String |
getHostname(EnvVars envVars)
Getter function to return either the saved hostname global configuration,
or the hostname that is set in the Jenkins host itself.
|
static String |
getItemName(Item item) |
static String |
getJenkinsUrl() |
static String |
getNodeHostname(EnvVars envVars,
Computer computer) |
static Set<String> |
getNodeLabels(Computer computer) |
static String |
getNodeName(Computer computer) |
static String |
getResultTag(org.jenkinsci.plugins.workflow.graph.FlowNode node) |
static Long |
getRunStartTimeInMillis(Run run) |
static Map<String,Set<String>> |
getTagsFromGlobalTags()
Getter function for the globalTags global configuration, containing
a comma-separated list of tags that should be applied everywhere.
|
static Map<String,Set<String>> |
getTagsFromPipelineAction(Run run)
Pipeline extraTags if any are configured in the Job from DatadogPipelineAction.
|
static TaskListener |
getTaskListener(Run run) |
static long |
getTimeMillis(org.jenkinsci.plugins.workflow.graph.FlowNode flowNode)
Returns the startTime of a certain
FlowNode , if it has time information. |
static String |
getUserId() |
static boolean |
isJobTracked(String jobName)
Checks if a jobName is excluded, included, or neither.
|
static boolean |
isMainNode(String nodeName) |
static boolean |
isStageNode(org.jenkinsci.plugins.workflow.graph.FlowNode flowNode)
Returns true if a
FlowNode is a Stage node. |
static Boolean |
isValidHostname(String hostname)
Validator function to ensure that the hostname is valid.
|
static List<String> |
linesToList(String str)
Converts a string List into a List Object
|
static void |
severe(Logger logger,
Throwable e,
String message) |
static boolean |
shouldSendEvent(String eventName)
Checks to see if event should be sent to client
|
static String |
statusFromResult(String result)
Returns a normalized result for traces.
|
static int |
toInt(boolean b) |
static String |
toISO8601(Date date)
Returns a date as String in the ISO8601 format
|
static String |
toJson(Map<String,String> map)
Returns a JSON object string based on the map.
|
static String |
toJson(Set<String> set)
Returns a JSON array string based on the set.
|
@Nullable public static DatadogGlobalConfiguration getDatadogGlobalDescriptor()
public static DatadogJobProperty getDatadogJobProperties(@Nonnull Run r)
r
- - Current build.DatadogJobProperty
. Null if not therepublic static Map<String,Set<String>> getBuildTags(Run run, EnvVars envVars)
run
- - Current buildenvVars
- - Environment VariablesHashMap
containing the key,value pairs of tags if any.public static Map<String,Set<String>> getTagsFromPipelineAction(Run run)
run
- - Current buildMap
containing the key,value pairs of tags if any.public static boolean isJobTracked(String jobName)
jobName
- - A String containing the name of some job.public static Map<String,Set<String>> getTagsFromGlobalTags()
public static List<String> cstrToList(String str)
str
- - A String containing a comma separated list of items.public static List<String> linesToList(String str)
str
- - A String containing a comma separated list of items.public static Map<String,Set<String>> computeTagListFromVarList(EnvVars envVars, String varList)
public static String getAwsInstanceID() throws IOException
IOException
public static String getHostname(EnvVars envVars)
Tries, in order: Jenkins configuration Jenkins hostname environment variable AWS instance ID, if enabled System hostname environment variable Unix hostname via `/bin/hostname -f` Localhost hostname
envVars
- - The Jenkins environment variablespublic static Boolean isValidHostname(String hostname)
hostname
- - A String object containing the name of a host.public static boolean isMainNode(String nodeName)
public static String getNodeHostname(@Nullable EnvVars envVars, @Nullable Computer computer)
public static String getUserId()
public static long currentTimeMillis()
public static String getJenkinsUrl()
public static String getResultTag(@Nonnull org.jenkinsci.plugins.workflow.graph.FlowNode node)
public static boolean isStageNode(org.jenkinsci.plugins.workflow.graph.FlowNode flowNode)
FlowNode
is a Stage node.flowNode
- the flow node to evaluatepublic static org.jenkinsci.plugins.workflow.graph.BlockStartNode getEnclosingStageNode(org.jenkinsci.plugins.workflow.graph.FlowNode node)
public static String statusFromResult(String result)
result
- (success, failure, error, aborted, not_build, canceled, skipped, unstable, unknown)public static int toInt(boolean b)
public static String toISO8601(Date date)
date
- the date object to transformpublic static String toJson(Set<String> set)
set
- the set to transform into a JSONpublic static String toJson(Map<String,String> map)
map
- the map to transform into a JSONpublic static void cleanUpTraceActions(Actionable actionable)
actionable
- a domain object that can contain actions, such as run or flow node.public static String getCatchErrorResult(org.jenkinsci.plugins.workflow.graph.BlockStartNode startNode)
public static boolean shouldSendEvent(String eventName)
eventName
- - the event to checkpublic static Throwable getErrorObj(org.jenkinsci.plugins.workflow.graph.FlowNode flowNode)
Throwable
of a certain FlowNode
, if it has errors.@Nullable public static TaskListener getTaskListener(Run run) throws IOException
IOException
public static long getTimeMillis(org.jenkinsci.plugins.workflow.graph.FlowNode flowNode)
FlowNode
, if it has time information.Copyright © 2016–2024. All rights reserved.