From 29e67467a6446f6412a6a897e81669eb5274090a Mon Sep 17 00:00:00 2001 From: miles-grant-ibi Date: Mon, 14 Jul 2025 16:31:36 -0400 Subject: [PATCH 1/3] add build log to deployment notification email --- .../manager/controllers/api/DeploymentController.java | 9 ++++++++- .../manager/jobs/NotifyUsersForSubscriptionJob.java | 7 +++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java b/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java index 9d43a6616..09aae5429 100644 --- a/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java +++ b/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java @@ -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)) { @@ -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 ); @@ -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); 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); diff --git a/src/main/java/com/conveyal/datatools/manager/jobs/NotifyUsersForSubscriptionJob.java b/src/main/java/com/conveyal/datatools/manager/jobs/NotifyUsersForSubscriptionJob.java index b21504168..c35af0dc9 100644 --- a/src/main/java/com/conveyal/datatools/manager/jobs/NotifyUsersForSubscriptionJob.java +++ b/src/main/java/com/conveyal/datatools/manager/jobs/NotifyUsersForSubscriptionJob.java @@ -64,6 +64,13 @@ public void notifyUsers() { deployment.projectId, deployment.id ); + // Add build log text. + html += String.format( + "

View deployment otp-build.log.

", + APPLICATION_URL, + deployment.id, + deployment.latest().jobId + ); break; default: LOG.warn("Notifications not supported for subscription type {}", subType[0]); From 3a121fc071f135c6faacdfd7db8688cd4dc9d997 Mon Sep 17 00:00:00 2001 From: miles-grant-ibi Date: Mon, 14 Jul 2025 16:33:36 -0400 Subject: [PATCH 2/3] clean up --- .../datatools/manager/controllers/api/DeploymentController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java b/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java index 09aae5429..cd7ac3d26 100644 --- a/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java +++ b/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java @@ -139,7 +139,7 @@ private static String downloadBuildArtifact (Request req, Response res) throws C } AmazonS3URI uri = new AmazonS3URI(uriString); - // If a redirect query param is provided, find the matching job summary. + // 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. From 554e78cd12208aafabb0a882587801e128f98d7d Mon Sep 17 00:00:00 2001 From: miles-grant-ibi Date: Thu, 17 Jul 2025 11:19:50 -0400 Subject: [PATCH 3/3] address pr feedback --- .../manager/controllers/api/DeploymentController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java b/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java index cd7ac3d26..2e996f0c9 100644 --- a/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java +++ b/src/main/java/com/conveyal/datatools/manager/controllers/api/DeploymentController.java @@ -607,8 +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 - get(apiPrefix + "secure/deployments/:id/artifact/:ignored", 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);