Merge remote-tracking branch 'origin/master' into ux-412

This commit is contained in:
Thorsten Scherler 2016-06-15 15:27:08 +09:00
commit ba3aedbb62
12 changed files with 93 additions and 34 deletions

View File

@ -12,7 +12,7 @@
"rules": {
"eol-last": 1,
"no-unused-vars": [1],
"max-len": [1, 120, 4],
"max-len": [1, 160, 4],
"no-underscore-dangle": [0],
"object-shorthand": [0, "always"],
"quote-props": [0, "as-needed"],

View File

@ -2,6 +2,7 @@
"extends": "@jenkins-cd/jenkins/react",
"rules": {
"react/jsx-no-bind": 0,
"no-unused-vars": [2, {"varsIgnorePattern": "^React$"}]
"no-unused-vars": [2, {"varsIgnorePattern": "^React$"}],
"max-len": [1, 160, 4]
}
}

View File

@ -6,7 +6,6 @@
<link href="/css/normalize.css" rel="stylesheet">
<!-- Icons -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link href="/css/latofonts.css" rel="stylesheet">
<link href="/octicons/octicons.css" rel="stylesheet">

View File

@ -17,7 +17,7 @@
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>sse-gateway</artifactId>
<version>1.2</version>
<version>1.3</version>
</dependency>
</dependencies>

View File

@ -21,6 +21,7 @@ export default class Branches extends Component {
location,
pipeline: {
name: pipelineName,
organization,
},
},
} = this;
@ -29,7 +30,7 @@ export default class Branches extends Component {
weatherScore,
name,
} = data;
const url = `/pipelines/${pipelineName}/detail/${name}/${id}/pipeline`;
const url = `/organizations/${organization}/${pipelineName}/detail/${name}/${id}/pipeline`;
const open = () => {
location.pathname = url;
router.push(location);

View File

@ -29,10 +29,11 @@ export default class PullRequest extends Component {
location,
pipeline: {
name: pipelineName,
organization,
},
},
} = this;
const url = `/pipelines/${pipelineName}/detail/${name}/${id}/pipeline`;
const url = `organizations/${organization}/${pipelineName}/detail/${name}/${id}/pipeline`;
const open = () => {
location.pathname = url;
router.push(location);

View File

@ -1,9 +1,10 @@
import React, { Component, PropTypes } from 'react';
import {
CommitHash, ReadableDate, StatusIndicator, TimeDuration,
CommitHash, ReadableDate, LiveStatusIndicator, TimeDuration,
}
from '@jenkins-cd/design-language';
import { removeLastUrlSegment } from '../util/UrlUtils';
import moment from 'moment';
const { object, string, any } = PropTypes;
@ -40,6 +41,8 @@ export default class Runs extends Component {
} = this;
const resultRun = result === 'UNKNOWN' ? state : result;
const estimatedDuration = this.context.pipeline.estimatedDurationInMillis;
const startTime = moment.parseZone(this.props.result.startTime).valueOf();
const baseUrl = removeLastUrlSegment(this.context.location.pathname);
const url = `${baseUrl}/detail/${pipeline}/${id}/pipeline`;
@ -50,7 +53,7 @@ export default class Runs extends Component {
return (<tr key={id} onClick={open} id={`${pipeline}-${id}`} >
<td>
<StatusIndicator result={resultRun} />
<LiveStatusIndicator result={resultRun} startTime={startTime} estimatedDuration={estimatedDuration} />
</td>
<td>
{id}

View File

@ -4,7 +4,8 @@ import path from 'path';
import {convertJenkinsNodeGraph} from '../../main/js/components/PipelineRunGraph.jsx';
import { pipelineStageState } from '@jenkins-cd/design-language/dist/js/components/PipelineGraph';
import {StatusIndicator} from '@jenkins-cd/design-language';
const validResultValues = StatusIndicator.validResultValues;
describe("pipeline graph data converter", () => {
@ -53,7 +54,7 @@ describe("pipeline graph data converter", () => {
assert.equal(result[0].name, "Deploy", "result[0].name");
assert.equal(result[0].id, "27", "result[0].id");
assert.equal(result[0].state, pipelineStageState.success, "result[0].state");
assert.equal(result[0].state, validResultValues.success, "result[0].state");
assert.equal(result[0].completePercent, 100, "result[0].completePercent");
assert(Array.isArray(result[0].children), "result[0].children should be array");
assert.equal(result[0].children.length, 0, "result[0] should have no children");
@ -82,21 +83,21 @@ describe("pipeline graph data converter", () => {
assert.equal(result[0].name, "First", "result[0].name");
assert.equal(result[0].id, "3", "result[0].id");
assert.equal(result[0].state, pipelineStageState.success, "result[0].state");
assert.equal(result[0].state, validResultValues.success, "result[0].state");
assert.equal(result[0].completePercent, 100, "result[0].completePercent");
assert(Array.isArray(result[0].children), "result[0].children should be array");
assert.equal(result[0].children.length, 0, "result[0] should have no children");
assert.equal(result[1].name, "Second", "result[1].name");
assert.equal(result[1].id, "13", "result[1].id");
assert.equal(result[1].state, pipelineStageState.running, "result[1].state");
assert.equal(result[1].state, validResultValues.running, "result[1].state");
assert.equal(result[1].completePercent, 50, "result[1].completePercent");
assert(Array.isArray(result[1].children), "result[1].children should be array");
assert.equal(result[1].children.length, 0, "result[1] should have no children");
assert.equal(result[2].name, "Third", "result[2].name");
assert.equal(result[2].id, "27", "result[2].id");
assert.equal(result[2].state, pipelineStageState.queued, "result[2].state");
assert.equal(result[2].state, validResultValues.queued, "result[2].state");
assert.equal(result[2].completePercent, 0, "result[2].completePercent");
assert(Array.isArray(result[1].children), "result[2].children should be array");
assert.equal(result[2].children.length, 0, "result[2] should have no children");
@ -126,21 +127,21 @@ describe("pipeline graph data converter", () => {
assert.equal(result[0].name, "Build", "result[0].name");
assert.equal(result[0].id, "3", "result[0].id");
assert.equal(result[0].state, pipelineStageState.success, "result[0].state");
assert.equal(result[0].state, validResultValues.success, "result[0].state");
assert.equal(result[0].completePercent, 100, "result[0].completePercent");
assert(Array.isArray(result[0].children), "result[0].children should be array");
assert.equal(result[0].children.length, 0, "result[0] should have no children");
assert.equal(result[1].name, "Test", "result[1].name");
assert.equal(result[1].id, "9", "result[1].id");
assert.equal(result[1].state, pipelineStageState.success, "result[1].state");
assert.equal(result[1].state, validResultValues.success, "result[1].state");
assert.equal(result[1].completePercent, 100, "result[1].completePercent");
assert(Array.isArray(result[1].children), "result[1].children should be array");
assert.equal(result[1].children.length, 2, "result[1] should have 2 children");
assert.equal(result[2].name, "Deploy", "result[2].name");
assert.equal(result[2].id, "27", "result[2].id");
assert.equal(result[2].state, pipelineStageState.success, "result[2].state");
assert.equal(result[2].state, validResultValues.success, "result[2].state");
assert.equal(result[2].completePercent, 100, "result[2].completePercent");
assert(Array.isArray(result[2].children), "result[2].children should be array");
assert.equal(result[2].children.length, 0, "result[2] should have no children");
@ -149,14 +150,14 @@ describe("pipeline graph data converter", () => {
assert.equal(children[0].name, "Firefox", "children[0].name");
assert.equal(children[0].id, "12", "children[0].id");
assert.equal(children[0].state, pipelineStageState.success, "children[0].state");
assert.equal(children[0].state, validResultValues.success, "children[0].state");
assert.equal(children[0].completePercent, 100, "children[0].completePercent");
assert(Array.isArray(children[0].children), "children[0].children should be array");
assert.equal(children[0].children.length, 0, "children[0] should have no children");
assert.equal(children[1].name, "Chrome", "children[1].name");
assert.equal(children[1].id, "13", "children[1].id");
assert.equal(children[1].state, pipelineStageState.success, "children[1].state");
assert.equal(children[1].state, validResultValues.success, "children[1].state");
assert.equal(children[1].completePercent, 100, "children[1].completePercent");
assert(Array.isArray(children[1].children), "children[1].children should be array");
assert.equal(children[1].children.length, 0, "children[1] should have no children");
@ -185,14 +186,14 @@ describe("pipeline graph data converter", () => {
assert.equal(result[0].name, "Build", "result[0].name");
assert.equal(result[0].id, "3", "result[0].id");
assert.equal(result[0].state, pipelineStageState.success, "result[0].state");
assert.equal(result[0].state, validResultValues.success, "result[0].state");
assert.equal(result[0].completePercent, 100, "result[0].completePercent");
assert(Array.isArray(result[0].children), "result[0].children should be array");
assert.equal(result[0].children.length, 0, "result[0] should have no children");
assert.equal(result[1].name, "Test", "result[1].name");
assert.equal(result[1].id, "9", "result[1].id");
assert.equal(result[1].state, pipelineStageState.success, "result[1].state");
assert.equal(result[1].state, validResultValues.success, "result[1].state");
assert.equal(result[1].completePercent, 100, "result[1].completePercent");
assert(Array.isArray(result[1].children), "result[1].children should be array");
assert.equal(result[1].children.length, 2, "result[1] should have 2 children");
@ -201,14 +202,14 @@ describe("pipeline graph data converter", () => {
assert.equal(children[0].name, "Firefox", "children[0].name");
assert.equal(children[0].id, "12", "children[0].id");
assert.equal(children[0].state, pipelineStageState.success, "children[0].state");
assert.equal(children[0].state, validResultValues.success, "children[0].state");
assert.equal(children[0].completePercent, 100, "children[0].completePercent");
assert(Array.isArray(children[0].children), "children[0].children should be array");
assert.equal(children[0].children.length, 0, "children[0] should have no children");
assert.equal(children[1].name, "Chrome", "children[1].name");
assert.equal(children[1].id, "13", "children[1].id");
assert.equal(children[1].state, pipelineStageState.success, "children[1].state");
assert.equal(children[1].state, validResultValues.success, "children[1].state");
assert.equal(children[1].completePercent, 100, "children[1].completePercent");
assert(Array.isArray(children[1].children), "children[1].children should be array");
assert.equal(children[1].children.length, 0, "children[1] should have no children");
@ -237,45 +238,45 @@ describe("pipeline graph data converter", () => {
assert.equal(result[0].name, "First", "result[0].name");
assert.equal(result[0].id, "3", "result[0].id");
assert.equal(result[0].state, pipelineStageState.success, "result[0].state");
assert.equal(result[0].state, validResultValues.success, "result[0].state");
assert.equal(result[0].completePercent, 100, "result[0].completePercent");
assert(Array.isArray(result[0].children), "result[0].children should be array");
assert.equal(result[0].children.length, 0, "result[0] should have no children");
assert.equal(result[1].name, "Second", "result[1].name");
assert.equal(result[1].id, "13", "result[1].id");
assert.equal(result[1].state, pipelineStageState.running, "result[1].state");
assert.equal(result[1].state, validResultValues.running, "result[1].state");
assert.equal(result[1].completePercent, 50, "result[1].completePercent");
assert(Array.isArray(result[1].children), "result[1].children should be array");
assert.equal(result[1].children.length, 0, "result[1] should have no children");
assert.equal(result[2].name, "Third", "result[2].name");
assert.equal(result[2].id, "27", "result[2].id");
assert.equal(result[2].state, pipelineStageState.queued, "result[2].state");
assert.equal(result[2].state, validResultValues.queued, "result[2].state");
assert.equal(result[2].completePercent, 0, "result[2].completePercent");
assert(Array.isArray(result[2].children), "result[2].children should be array");
assert.equal(result[2].children.length, 0, "result[2] should have no children");
assert.equal(result[3].name, "Fourth", "result[3].name");
assert.equal(result[3].id, "28", "result[3].id");
assert.equal(result[3].state, pipelineStageState.failure, "result[3].state");
assert.equal(result[3].state, validResultValues.failure, "result[3].state");
assert.equal(result[3].completePercent, 100, "result[3].completePercent");
assert(Array.isArray(result[3].children), "result[3].children should be array");
assert.equal(result[3].children.length, 0, "result[3] should have no children");
assert.equal(result[4].name, "Steve", "result[4].name");
assert.equal(result[4].id, "29", "result[4].id");
assert.equal(result[4].state, pipelineStageState.notBuilt, "result[4].state");
assert.equal(result[4].state, validResultValues.not_built, "result[4].state");
assert.equal(result[4].completePercent, 0, "result[4].completePercent");
assert(Array.isArray(result[4].children), "result[4].children should be array");
assert.equal(result[4].children.length, 0, "result[4] should have no children");
assert.equal(result[5].name, "Unknown-Null", "result[5].name");
assert.equal(result[5].id, "33", "result[5].id");
assert.equal(result[5].state, pipelineStageState.queued, "result[5].state");
assert.equal(result[5].state, validResultValues.queued, "result[5].state");
assert.equal(result[5].completePercent, 0, "result[5].completePercent");
assert(Array.isArray(result[5].children), "result[5].children should be array");
assert.equal(result[5].children.length, 0, "result[5] should have no children");
});
});
});
});

View File

@ -27,11 +27,11 @@ public class PipelineNodeContainerImpl extends BluePipelineNodeContainer {
WorkflowJob job = run.getParent();
PipelineNodeGraphBuilder graphBuilder = new PipelineNodeGraphBuilder(run);
//If build either failed or is in progress then return union with last successful pipeline run
if(job.getLastBuild() != null
&& job.getLastBuild().getResult() != Result.SUCCESS
if(run.getResult() != Result.SUCCESS
&& job.getLastSuccessfulBuild() != null
&& !job.getLastSuccessfulBuild().getId().equals(job.getLastBuild().getId())){
&& Integer.valueOf(job.getLastSuccessfulBuild().getId()) < Integer.valueOf(run.getId())){
PipelineNodeGraphBuilder pastBuild = new PipelineNodeGraphBuilder(job.getLastSuccessfulBuild());
this.nodes = graphBuilder.union(pastBuild);
}else{

View File

@ -57,7 +57,7 @@ public class PipelineNodeGraphBuilder {
Iterables.addAll(nodeTreeSet, new FlowGraphWalker(run.getExecution()));
}
this.sortedNodes = Collections.unmodifiableList(new ArrayList<>(nodeTreeSet));
// dumpNodes();
// dumpNodes(sortedNodes);
build();
}

View File

@ -18,6 +18,60 @@ import java.util.Map;
* @author Vivek Pandey
*/
public class PipelineNodeTest extends BaseTest {
@Test
public void nodesWithFutureTest() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");
job1.setDefinition(new CpsFlowDefinition("node {\n" +
" stage 'build'\n" +
" sh 'echo s1'\n" +
" stage 'test'\n" +
" echo 'Hello World 2'\n" +
"}"));
WorkflowRun b1 = job1.scheduleBuild2(0).get();
j.assertBuildStatus(Result.SUCCESS,b1);
get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/", List.class);
job1.setDefinition(new CpsFlowDefinition("node {\n" +
" stage 'build'\n" +
" sh 'echo s1'\n" +
" stage 'test'\n" +
" echo 'Hello World 2'\n" +
"}\n" +
"parallel firstBranch: {\n" +
" echo 'Hello first'\n" +
"}, secondBranch: {\n" +
" echo 'Hello second'\n" +
"}"));
WorkflowRun b2 = job1.scheduleBuild2(0).get();
j.assertBuildStatus(Result.SUCCESS,b2);
job1.setDefinition(new CpsFlowDefinition("node {\n" +
" stage 'build'\n" +
" sh 'echo s1'\n" +
" stage 'test'\n" +
" echo 'Hello World 2'\n" +
"}\n" +
"parallel firstBranch: {\n" +
" echo 'Hello first'\n" +
"}, secondBranch: {\n" +
" sh 'Hello second'\n" +
"}"));
WorkflowRun b3 = job1.scheduleBuild2(0).get();
j.assertBuildStatus(Result.FAILURE,b3);
List<Map> resp = get("/organizations/jenkins/pipelines/pipeline1/runs/1/nodes/", List.class);
Assert.assertEquals(2, resp.size());
}
@Test
public void nodesTest() throws Exception {
WorkflowJob job1 = j.jenkins.createProject(WorkflowJob.class, "pipeline1");

View File

@ -22,7 +22,6 @@
<link href="${resURL}/plugin/blueocean-web/assets/css/normalize.css" rel="stylesheet"/>
<!-- Icons + Fonts -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/>
<link rel="stylesheet" href="${resURL}/plugin/blueocean-web/assets/css/latofonts.css" type="text/css"/>
<link rel="stylesheet" href="${resURL}/plugin/blueocean-web/assets/octicons/octicons.css" type="text/css"/>