diff --git a/src/main/java/testingbot/TestingBotBuildObject.java b/src/main/java/testingbot/TestingBotBuildObject.java index b7cb564..100c02f 100644 --- a/src/main/java/testingbot/TestingBotBuildObject.java +++ b/src/main/java/testingbot/TestingBotBuildObject.java @@ -11,7 +11,6 @@ public class TestingBotBuildObject implements Serializable { private String testName; private final boolean isPassed; private String authHash; - private TestingbotTest test; private String environmentName; public TestingBotBuildObject(String sessionId, String className, String testName, boolean isPassed, String authHash, TestingbotTest test) { @@ -20,7 +19,8 @@ public TestingBotBuildObject(String sessionId, String className, String testName this.testName = testName; this.isPassed = isPassed; this.authHash = authHash; - this.test = test; + // TestingbotTest is only used here to derive the environment label; it is not stored (it is not + // marshalable under the JEP-200 class filter, and nothing reads it afterwards). this.environmentName = test == null ? "" : test.getBrowser() + " | " + test.getOs(); } @@ -81,20 +81,6 @@ public boolean getIsPassed() { return isPassed; } - /** - * @return the test - */ - public TestingbotTest getTest() { - return test; - } - - /** - * @param test the test to set - */ - public void setTest(TestingbotTest test) { - this.test = test; - } - /** * @return the authHash */ diff --git a/src/main/java/testingbot/TestingBotTestEmbed.java b/src/main/java/testingbot/TestingBotTestEmbed.java index 10dc935..05a6a5a 100644 --- a/src/main/java/testingbot/TestingBotTestEmbed.java +++ b/src/main/java/testingbot/TestingBotTestEmbed.java @@ -2,21 +2,16 @@ import hudson.model.Run; import jenkins.model.RunAction2; -import org.kohsuke.stapler.Stapler; -import org.kohsuke.stapler.StaplerRequest; -import org.kohsuke.stapler.StaplerResponse; +import org.kohsuke.stapler.StaplerRequest2; +import org.kohsuke.stapler.StaplerResponse2; -import javax.servlet.ServletException; +import jakarta.servlet.ServletException; import java.io.IOException; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; public class TestingBotTestEmbed implements RunAction2 { - private static final Logger logger = Logger.getLogger(TestingBotTestEmbed.class.getName()); private transient Run run; private List ids; - private TestingBotBuildObject tbo; public TestingBotTestEmbed(List ids) { this.ids = ids; @@ -48,32 +43,28 @@ public void onLoad(Run run) { } /** - * * @param req Standard Request Object * @param rsp Standard Response Object - * @throws IOException Unable to load show.jelly template + * @throws IOException Unable to load the view template */ @SuppressWarnings("unused") // used by stapler - public void doIndex(StaplerRequest req, StaplerResponse rsp) + public void doIndex(StaplerRequest2 req, StaplerResponse2 rsp) throws IOException { String sessionId = req.getParameter("sessionId"); - for (TestingBotBuildObject tbo : this.ids) { - if (tbo.getSessionId().equals(sessionId)) { - this.tbo = tbo; + TestingBotBuildObject selected = null; + for (TestingBotBuildObject candidate : this.ids) { + if (candidate.getSessionId().equals(sessionId)) { + selected = candidate; + break; } } - if (this.tbo != null) { - try { - req.getView(this, "show.jelly").forward(req, rsp); - } catch (ServletException e) { - throw new IOException(e); - } - } else { - try { - req.getView(this, "index.jelly").forward(req, rsp); - } catch (ServletException e) { - throw new IOException(e); - } + // Pass the selection through the request (this action is shared across concurrent requests, + // so a per-instance field would let requests overwrite each other's selected session). + req.setAttribute("tbo", selected); + try { + req.getView(this, selected != null ? "show.jelly" : "index.jelly").forward(req, rsp); + } catch (ServletException e) { + throw new IOException(e); } } @@ -81,10 +72,6 @@ public Run getRun() { return run; } - public TestingBotBuildObject getTbo() { - return tbo; - } - public List getSessionIds() { return ids; } diff --git a/src/main/resources/testingbot/TestingBotTestEmbed/show.jelly b/src/main/resources/testingbot/TestingBotTestEmbed/show.jelly index 9daf2a1..1f23d1e 100644 --- a/src/main/resources/testingbot/TestingBotTestEmbed/show.jelly +++ b/src/main/resources/testingbot/TestingBotTestEmbed/show.jelly @@ -5,11 +5,12 @@ -

${it.tbo.testName}

- View on TestingBot + +

${tbo.testName}

+ View on TestingBot
- +