Skip to content

Commit

Permalink
feat(pipeline): support for parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 2, 2021
1 parent 20cbea3 commit 21d05f1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 29 deletions.
73 changes: 47 additions & 26 deletions web/fake/pipeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,48 +3,69 @@
"name": "",
"stages": [
{
"name": "versions",
"name": "initialize",
"steps": [
"sh \"java -version\"\n ",
"sh \"docker version\"\n ",
"sh \"docker-compose version\"\n "
"checkout scm"
],
"is_parallel": false,
"sub_stages": []
},
{
"name": "test-go",
"name": "install",
"steps": [
"sh \"go get -d -v -t && go test --cover -v ./... --run UnitTest && go build -v -o go-demo\"\n "
"sh 'yarn install --frozen-lockfile'\n ",
"stash includes: 'node_modules', name: 'dependencies'\n "
],
"is_parallel": false,
"sub_stages": []
},
{
"name": "test-docker",
"steps": [
"sh \"docker container run -v ${workspace}:/usr/src/myapp -w /usr/src/myapp golang:1.9 bash -c \\\"go get -d -v -t && go test --cover -v ./... --run UnitTest && go build -v -o go-demo\\\"\"\n "
],
"name": "parallel",
"steps": [],
"is_parallel": false,
"sub_stages": []
},
{
"name": "test-dc",
"steps": [
"sh \"docker-compose run --rm unit\"\n "
],
"is_parallel": false,
"sub_stages": []
"sub_stages": [
{
"name": "build",
"steps": [
"unstash 'dependencies'\n ",
"sh 'yarn build'\n "
],
"is_parallel": false,
"sub_stages": []
},
{
"name": "lint",
"steps": [
"unstash 'dependencies'\n ",
"sh 'yarn --silent lint --format junit --output-file eslint.xml'\n "
],
"is_parallel": false,
"sub_stages": []
},
{
"name": "test",
"steps": [
"unstash 'dependencies'\n ",
"sh 'yarn --silent test --reporter xunit > junit.xml'\n "
],
"is_parallel": false,
"sub_stages": []
},
{
"name": "documentation",
"steps": [
"unstash 'dependencies'\n ",
"sh 'yarn --silent documentation'\n "
],
"is_parallel": false,
"sub_stages": []
}
]
},
{
"name": "release",
"name": "publish",
"steps": [
"script {\n def dateFormat = new SimpleDateFormat(\"yy.MM.dd\")\n currentBuild.displayName = dateFormat.format(new Date()) + \"-\" + env.BUILD_NUMBER\n }",
"sh \"docker image build -t vfarcic/go-demo-cje .\"\n ",
"sh \"docker image tag vfarcic/go-demo-cje vfarcic/go-demo-cje:${currentBuild.displayName}\"\n ",
"withCredentials([usernamePassword(\n credentialsId: \"docker\",\n usernameVariable: \"USER\",\n passwordVariable: \"PASS\"\n )]) {\n sh \"docker login -u '$USER' -p '$PASS'\"\n }",
"sh \"docker image push vfarcic/go-demo-cje\"\n ",
"sh \"docker image push vfarcic/go-demo-cje:${currentBuild.displayName}\"\n "
"echo 'Publishing...'\n "
],
"is_parallel": false,
"sub_stages": []
Expand Down
1 change: 1 addition & 0 deletions web/public/js/graph/plugins/pipeline-visual.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ function visualizationPipeline(data, elementId) {
})
}));

console.log(stages);

let svg = d3.select(elementId)
.append('svg')
Expand Down
15 changes: 12 additions & 3 deletions web/public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,21 @@ d3.json("fake/pipeline.json").then(function (data) {
let first_pipeline = data[0];
for (let stage of first_pipeline.stages) {
let jobs = [];
for (let step of stage.steps) {
jobs.push({name: step});
for (let sub_stage of stage.sub_stages) {
jobs.push({
name: sub_stage.name,
desc: jobs,
});
}
if (jobs.length === 0) {
jobs.push({
name: "",
desc: jobs,
});
}
pipeline.push({
name: stage.name,
children: jobs
children: jobs,
})
}

Expand Down

0 comments on commit 21d05f1

Please sign in to comment.