Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add build log to deployment notification email
  • Loading branch information
miles-grant-ibigroup committed Jul 14, 2025
commit 29e67467a6446f6412a6a897e81669eb5274090a
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private static String downloadBuildArtifact (Request req, Response res) throws C
}
// If a jobId query param is provided, find the matching job summary.
String jobId = req.queryParams("jobId");

if (jobId != null) {
for (DeployJob.DeploySummary summary : deployment.deployJobSummaries) {
if (summary.jobId.equals(jobId)) {
Expand Down Expand Up @@ -137,12 +138,16 @@ private static String downloadBuildArtifact (Request req, Response res) throws C
region = summaryToDownload.ec2Info == null ? null : summaryToDownload.ec2Info.region;
}
AmazonS3URI uri = new AmazonS3URI(uriString);

// If a redirect query param is provided, find the matching job summary.
boolean redirect = Boolean.parseBoolean(req.queryParams("redirect"));

// Assume the alternative role if needed to download the deploy artifact.
return S3Utils.downloadObject(
S3Utils.getS3Client(role, region),
uri.getBucket(),
String.join("/", uri.getKey(), filename),
false,
redirect,
req,
res
);
Expand Down Expand Up @@ -602,6 +607,8 @@ public static void register (String apiPrefix) {
options(apiPrefix + "secure/deployments", (q, s) -> "");
get(apiPrefix + "secure/deployments/:id/download", DeploymentController::downloadDeployment);
get(apiPrefix + "secure/deployments/:id/artifact", DeploymentController::downloadBuildArtifact);
// This path allows the downloaded artifact file to be named anything
get(apiPrefix + "secure/deployments/:id/artifact/:ignored", DeploymentController::downloadBuildArtifact);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miles-grant-ibigroup This is confusing me. If the value is ignored, why can't the end point above be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without it, we can't make a call to .../artifact/blah.json which means we have to call it as .../artifact which means the downloaded file is downloaded as artifact which is no good.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that makes sense. Can you update the comment with this explanation please and perhaps call it :expectedFileName instead of :ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

get(apiPrefix + "secure/deployments/:id/ec2", DeploymentController::fetchEC2InstanceSummaries, slimJson::write);
delete(apiPrefix + "secure/deployments/:id/ec2", DeploymentController::terminateEC2InstanceForDeployment, slimJson::write);
get(apiPrefix + "secure/deployments/:id", DeploymentController::getDeployment, fullJson::write);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public void notifyUsers() {
deployment.projectId,
deployment.id
);
// Add build log text.
html += String.format(
"<p>View <a href='%s/api/manager/secure/deployments/%s/artifact/otp-build.log?filename=otp-build.log&jobId=%s&redirect=true'>deployment otp-build.log</a>.</p>",
APPLICATION_URL,
deployment.id,
deployment.latest().jobId
);
break;
default:
LOG.warn("Notifications not supported for subscription type {}", subType[0]);
Expand Down
Loading