Class BuildData
- java.lang.Object
-
- org.datadog.jenkins.plugins.datadog.model.BuildData
-
- All Implemented Interfaces:
Serializable
public class BuildData extends Object implements Serializable
- See Also:
- Serialized Form
-
-
Method Summary
-
-
-
Method Detail
-
create
@Nonnull public static BuildData create(@Nullable Run<?,?> run, @Nullable TaskListener listener)
This is a workaround for a BuildData initialization issue.Some of the fields in this class are initialized with the values obtained from a Run instance. Querying Run fields can trigger run initialization in some cases (e.g. loading run data from disk when resuming a run after Jenkins restart). During run initialization some logs are written. Writing logs, in turn, requires creating a TaskListener associated with the run. Creating the listener triggers initialization of DatadogTaskListenerDecorator, as the listener's logger needs to be decorated. The decorator creates another BuildData instance, whose creation starts the whole cycle from the beginning. As the result, the code enters an endless cycle of initializing BuildData while initializing BuildData, which terminates with a stack overflow.
The code below checks that BuildData for the provided run is already being created in the current thread. If that is the case, empty BuildData instance is returned for the nested calls in order to break the cycle. As a side effect, whatever logs are written while Run instance is being initialized will not be tagged with that run's data.
-
getTags
public Map<String,Set<String>> getTags()
Assembles a map of tags containing: - Build Tags - Global Job Tags set in Job Properties - Global Tag set in Jenkins Global configuration- Returns:
- a map containing all tags values
-
getJobName
@Nonnull public String getJobName()
-
isCompleted
public boolean isCompleted()
-
isBuilding
public boolean isBuilding()
-
setHostname
public void setHostname(String hostname)
-
getCharset
public Charset getCharset()
-
getTotalQueueTimeMillis
public long getTotalQueueTimeMillis()
Returns the total time this build spent waiting in queue.
-
getVersion
public Integer getVersion()
-
getTraceId
public Long getTraceId()
-
getSpanId
public Long getSpanId()
-
setJenkinsUrl
public void setJenkinsUrl(String jenkinsUrl)
-
getGitMetadata
public GitMetadata getGitMetadata()
-
getPipelineDefinitionGitMetadata
public GitMetadata getPipelineDefinitionGitMetadata()
For multi-branch pipelines it is possible to check out pipeline definition from one repository, then, when executing the pipeline script, do another Git checkout from a different repository. This method returns Git metadata for original pipeline script checkout
-
getUserId
public String getUserId()
-
getUpstreamPipelineUrl
@Nullable public String getUpstreamPipelineUrl()
-
getUpstreamPipelineTraceId
@Nullable public Long getUpstreamPipelineTraceId()
-
addLogAttributes
public net.sf.json.JSONObject addLogAttributes()
-
isStartTimeKnown
public boolean isStartTimeKnown()
The accurate start time for a pipeline (WorkflowRun) is only known once the first step starts executing (everything before that counts as queued time: see the definition ofpropagatedMillisInQueue
)
-
-