Skip to content

Add build log to deployment notification email #631

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
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, pass it along to the download method.
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,9 @@ 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. Without this line, the downloaded file
// will be named `artifact`.
get(apiPrefix + "secure/deployments/:id/artifact/:expectedFileName", DeploymentController::downloadBuildArtifact);
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