Skip to content

Commit

Permalink
Job URL to be stashed on QD
Browse files Browse the repository at this point in the history
  • Loading branch information
darpanLalwani committed Apr 4, 2024
1 parent 3038d48 commit 5f76666
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,16 @@ private void sendBuildDataToQD(Run run, Result overallResult, String finalZipPat
String jobName = run.getParent().getFullName();
int buildNumber = run.getNumber();
long endTimeInMillis = run.getTimeInMillis();

Jenkins jenkins = Jenkins.getInstanceOrNull();
String rootUrl = jenkins !=null ? jenkins.getRootUrl() : null;
String jobUrl = null;
if(rootUrl != null) {
jobUrl = rootUrl + run.getUrl();
}

Timestamp endTime = new Timestamp(endTimeInMillis);
PipelineResults pipelineResultsReqObj = new PipelineResults(buildNumber, pipelineDuration, overallResult.toString(), finalZipPath, jobName, endTime);
PipelineResults pipelineResultsReqObj = new PipelineResults(buildNumber, pipelineDuration, overallResult.toString(), finalZipPath, jobName, endTime, jobUrl);
ObjectMapper objectMapper = new ObjectMapper();
String jsonBody = objectMapper.writeValueAsString(pipelineResultsReqObj);

Expand Down Expand Up @@ -292,6 +300,9 @@ class PipelineResults implements Serializable {
@JsonProperty("buildDuration")
private Long buildDuration;

@JsonProperty("jobUrl")
private String jobUrl;

@JsonProperty("endTime")
private Timestamp endTime;
@JsonProperty("buildStatus")
Expand All @@ -300,12 +311,13 @@ class PipelineResults implements Serializable {
@JsonProperty("zipFile")
private String zipFile;

public PipelineResults(Integer buildNumber, Long buildDuration, String buildStatus, String zipFile, String pipelineName, Timestamp endTime) {
public PipelineResults(Integer buildNumber, Long buildDuration, String buildStatus, String zipFile, String pipelineName, Timestamp endTime, String jobUrl) {
this.buildNumber = buildNumber;
this.buildDuration = buildDuration;
this.buildStatus = buildStatus;
this.zipFile = zipFile;
this.pipelineName = pipelineName;
this.endTime = endTime;
this.jobUrl = jobUrl;
}
}

0 comments on commit 5f76666

Please sign in to comment.