Skip to content

Commit a55f6f4

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents cc5585f + 6778d61 commit a55f6f4

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

src/job.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,12 @@ export class Job {
6363
jobData = deepExtend.apply(this, deepExtendList);
6464
}
6565

66-
this.stage = jobData.stage;
66+
// If the stage name is not set, it should default to "test", see:
67+
// https://docs.gitlab.com/ee/ci/yaml/#configuration-parameters
68+
this.stage = jobData.stage || "test";
6769
this.scripts = [].concat(jobData.script || []);
6870

6971
this.stageIndex = stages.indexOf(this.stage);
70-
if (this.stageIndex === -1) {
71-
this.stage = stages[0];
72-
}
7372

7473
const jobNameStr = this.getJobNameString();
7574

src/parser.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,21 @@ export class Parser {
4747
// Setup variables and "merged" yml
4848
const gitlabData = deepExtend.apply(this, yamlDataList);
4949

50-
// Generate stages
50+
// Generate stages. We'll do our best to replicate what the
51+
// gitlab-org runner does.
52+
53+
// If there's no stages defined by the user, the following stages
54+
// must be defined. Please see:
55+
// https://docs.gitlab.com/ee/ci/yaml/#stages
56+
if (!gitlabData.stages) {
57+
gitlabData.stages = ["build", "test", "deploy"];
58+
}
59+
60+
// ".pre" and ".post" are always present. See:
61+
// https://docs.gitlab.com/ee/ci/yaml/#pre-and-post
62+
gitlabData.stages.unshift(".pre");
63+
gitlabData.stages.push(".post");
64+
5165
for (const value of gitlabData.stages || []) {
5266
this.stages.set(value, new Stage(value));
5367
}

0 commit comments

Comments
 (0)