From 5d4741676098f82ff1276d8855155329c87e51e0 Mon Sep 17 00:00:00 2001 From: Isaac Turner Date: Thu, 7 Dec 2023 14:11:22 +0800 Subject: [PATCH] write to build/ instead --- .../first/gradlerio/deploy/DeployData.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/wpi/first/gradlerio/deploy/DeployData.java b/src/main/java/edu/wpi/first/gradlerio/deploy/DeployData.java index 1f40c965..6f8746ee 100644 --- a/src/main/java/edu/wpi/first/gradlerio/deploy/DeployData.java +++ b/src/main/java/edu/wpi/first/gradlerio/deploy/DeployData.java @@ -10,12 +10,12 @@ import java.util.Map; import org.gradle.api.GradleException; -import org.gradle.internal.impldep.software.amazon.ion.IonException; import java.util.HashMap; import java.io.IOException; import java.io.File; import java.lang.Runtime; +import java.time.LocalDateTime; class DeployLogFile { public String deployHost; @@ -25,7 +25,7 @@ class DeployLogFile { public String gitHash; public String gitBranch; public String gitDesc; - public static final String LOG_FILE_PATH = "deploy.json"; + public static final String LOG_FILE_PATH = "/tmp/deploy.json"; public File deployFile; public String[] deployItems = { "deployHost", @@ -52,9 +52,20 @@ class DeployLogFile { inGitRepo = false; } - data.put(deployItems[0], deployHost); + try { + deployHost = Runtime.getRuntime().exec("hostname").getOutputStream().toString().strip(); + data.put(deployItems[0], deployHost); + } catch (IOException e) { + throw new GradleException("Couldn't get hostname", e); + } + + deployUser = System.getProperty("user.name"); data.put(deployItems[1], deployUser); + + deployDate = LocalDateTime.now().toString(); data.put(deployItems[2], deployDate); + + codePath = System.getProperty("user.dir"); data.put(deployItems[3], codePath); if (inGitRepo) { @@ -93,7 +104,7 @@ class DeployLogFile { throw new GradleException("Couldn't write deploy log file", e); } - deployArtifact = new FileArtifact(LOG_FILE_PATH, target); + deployArtifact = new FileArtifact("/home/lvuser/deploy.json", target); target.getArtifacts().add(deployArtifact); }