Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/main/frontend/common/RestClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export async function getExceptionText(stepId: string): Promise<string[]> {
const response = await fetch(`exceptionText?nodeId=${stepId}`);
if (!response.ok) throw response.statusText;
const text = await response.text();
if (!text) return [];
return text.split("\n");
} catch (e) {
console.error(`Caught error when fetching console: '${e}'`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@
run.checkPermission(Item.READ);
String nodeId = req.getParameter("nodeId");
if (nodeId == null) return HttpResponses.error(400, "missing ?nodeId");
return HttpResponses.text(getNodeExceptionText(nodeId));
String exceptionText = getNodeExceptionText(nodeId);
return HttpResponses.text(exceptionText != null ? exceptionText : "");

Check warning on line 189 in src/main/java/io/jenkins/plugins/pipelinegraphview/consoleview/PipelineConsoleViewAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 189 is only partially covered, one branch is missing
}

private AnnotatedLargeText<? extends FlowNode> getLogForNode(String nodeId) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,42 @@ void searchOffScreen(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
.scrollToText("Hello, world 1000!")
.scrollToText("Hello, world 1!");
}

@Test
@ConfiguredWithCode("configure-appearance.yml")
void errorWithMessage(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "gh1169";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "gh1169_errorWithMessage.jenkinsfile", Result.FAILURE);

// Note that the locator used in stageHasSteps accumulates the error step's message text content into the found
// step name so we just check that instead of also calling stepContainText
new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.hasStagesInGraph(1, "Stage")
.selectStageInGraph("Stage")
.stageHasSteps("Error signalError");
}

@Issue("GH#1169")
@Test
@ConfiguredWithCode("configure-appearance.yml")
void errorWithNoMessage(Page p, JenkinsConfiguredWithCodeRule j) throws Exception {
String name = "gh1169";
WorkflowRun run = TestUtils.createAndRunJob(j, name, "gh1169_errorWithNoMessage.jenkinsfile", Result.FAILURE);

new PipelineJobPage(p, run.getParent())
.goTo()
.hasBuilds(1)
.nthBuild(0)
.goToBuild()
.goToPipelineOverview()
.hasStagesInGraph(1, "Stage")
.selectStageInGraph("Stage")
.stageHasSteps("Error signal")
.stepDoesNotContainText("Error signal", "null");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ public void stepContainsText(String stepName, String textToFind) {
}
}

public void stepDoesNotContainText(String stepName, String textToNotFind) {
log.info("Checking that the step {} does not contain a log with the text {}", stepName, textToNotFind);

Locator stepContainer = steps().filter(new Locator.FilterOptions()
.setHas(page.locator(
STEP_NAME_CLASS,
new Page.LocatorOptions().setHasText(Pattern.compile("^" + stepName + "$")))))
.first();

if (!isOpenStep(stepContainer)) {
stepContainer.click();
}
Locator stepLogs = stepContainer.getByRole(AriaRole.LOG);
assertThat(stepLogs).not().containsText(textToNotFind);

Locator plainTextLogsLink = stepContainer.getByRole(
AriaRole.LINK, new Locator.GetByRoleOptions().setName("View step as plain text"));
try (Page plainText = page.context().waitForPage(plainTextLogsLink::click)) {
assertThat(plainText.locator("body")).not().containsText(textToNotFind);
}
}

public void stageHasSteps(String step, String... additional) {
List<String> expectedSteps = new ArrayList<>();
expectedSteps.add(step);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public PipelineOverviewPage stepContainsText(String stepName, String textToFind)
return this;
}

public PipelineOverviewPage stepDoesNotContainText(String stepName, String textToNotFind) {
logs.stepDoesNotContainText(stepName, textToNotFind);
return this;
}

public PipelineOverviewPage stageHasSteps(String step, String... additional) {
logs.stageHasSteps(step, additional);
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stage("Stage") {
error("Error")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
stage("Stage") {
error()
}
Loading