[feature/JENKINS-36211] Add stage_id to event emitter so we can listen on changes and focus a new flowNode. Listen on events to refetch the step data. Fix tests and update test data.

This commit is contained in:
Thorsten Scherler 2016-06-28 22:00:54 +02:00
parent ee3ecadf55
commit 79daf68fd2
5 changed files with 15 additions and 11 deletions

View File

@ -44,9 +44,9 @@ describe("Logic test of different runs", () => {
it("handles running", () => {
const runningSamples = [runNodesRunning, firstRunning, firstFinishedSecondRunning];
runningSamples
.map((item) => assertResult(
.map((item, index) => assertResult(
getNodesInformation(item),
{finished: false, failed: null, running: 1}
{finished: false, failed: null, running: index === 2 ? 3 : 1}
));
});
});

View File

@ -43,9 +43,9 @@ export const firstFinishedSecondRunning = [
"durationInMillis": 7269,
"edges": [],
"id": "16",
"result": "SUCCESS",
"result": "UNKOWN",
"startTime": "2016-05-25T13:47:50.800+0200",
"state": "FINISHED"
"state": "RUNNING"
},
{
"_class": "io.jenkins.blueocean.service.embedded.rest.PipelineNodeImpl",
@ -53,9 +53,9 @@ export const firstFinishedSecondRunning = [
"durationInMillis": 7268,
"edges": [],
"id": "17",
"result": "SUCCESS",
"result": "UNKOWN",
"startTime": "2016-05-25T13:47:50.801+0200",
"state": "FINISHED"
"state": "RUNNING"
},
{
"_class": "io.jenkins.blueocean.service.embedded.rest.PipelineNodeImpl",
@ -63,8 +63,8 @@ export const firstFinishedSecondRunning = [
"durationInMillis": 7267,
"edges": [],
"id": "18",
"result": "SUCCESS",
"result": "UNKOWN",
"startTime": "2016-05-25T13:47:50.802+0200",
"state": "FINISHED"
"state": "RUNNING"
}
]

View File

@ -22,7 +22,7 @@ describe("Store should work", () => {
})
it("create store with pipeline data", () => {
var ruleId = '/rest/organizations/jenkins/pipelines/';
nock('http://example.com/')
nock('http://example.com')
.get(ruleId)
.reply(200, pipelines);
const store = mockStore({ adminStore: {pipelines: [] }});
@ -36,8 +36,8 @@ describe("Store should work", () => {
});
});
it("create store with branch data", () => {
var ruleId = '/rest/organizations/jenkins/pipelines/xxx/runs';
var baseUrl = 'http://example.com/';
var ruleId = '/rest/organizations/jenkins/pipelines/xxx/runs/';
var baseUrl = 'http://example.com';
nock(baseUrl)
.get(ruleId)
.reply(200, latestRuns);

View File

@ -52,5 +52,6 @@ public interface PipelineEventChannel {
pipeline_step_name,
pipeline_step_flownode_id,
pipeline_step_stage_name,
pipeline_step_stage_id,
}
}

View File

@ -46,6 +46,7 @@ public class PipelineEventListener extends RunListener<Run<?,?>> {
private final Run run;
private final PubsubBus pubSubBus;
private String currentStageName;
private String currentStageId;
public StageEventPublisher(Run r) {
this.run = r;
@ -67,6 +68,7 @@ public class PipelineEventListener extends RunListener<Run<?,?>> {
if (stageAction != null) {
currentStageName = stageAction.getStageName();
currentStageId = flowNode.getId();
}
publishEvent(newMessage(PipelineEventChannel.Event.pipeline_step, flowNode, branch));
} else if (flowNode instanceof StepEndNode) {
@ -149,6 +151,7 @@ public class PipelineEventListener extends RunListener<Run<?,?>> {
message.set(PipelineEventChannel.EventProps.pipeline_context, toPath(branch));
if (currentStageName != null) {
message.set(PipelineEventChannel.EventProps.pipeline_step_stage_name, currentStageName);
message.set(PipelineEventChannel.EventProps.pipeline_step_stage_id, currentStageId);
}
if (flowNode instanceof StepNode) {
StepNode stepNode = (StepNode) flowNode;