Skip to content

Commit e7cf57c

Browse files
author
yang.guo
authored
Merge pull request #168 from FlowCI/feature/163
Feature/163
2 parents ad44e91 + e3c3db7 commit e7cf57c

File tree

6 files changed

+11
-6
lines changed

6 files changed

+11
-6
lines changed

platform-api/src/main/java/com/flow/platform/api/envs/FlowEnvs.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
public enum FlowEnvs implements EnvKey {
2727

28+
FLOW_NAME(true, false, null),
29+
2830
/**
2931
* Indicate flow is configured for git
3032
*/

platform-api/src/main/java/com/flow/platform/api/service/job/JobServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ private Job createJob(String path, JobCategory eventType, Map<String, String> en
331331
job.setUpdatedAt(ZonedDateTime.now());
332332

333333
// setup job env variables
334+
job.putEnv(FlowEnvs.FLOW_NAME, root.getName());
334335
job.putEnv(JobEnvs.FLOW_JOB_BUILD_CATEGORY, eventType.name());
335336
job.putEnv(JobEnvs.FLOW_JOB_BUILD_NUMBER, job.getNumber().toString());
336337
job.putEnv(JobEnvs.FLOW_JOB_LOG_PATH, logUrl(job));

platform-api/src/main/java/com/flow/platform/api/service/node/NodeServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public Node createEmptyFlow(final String flowName) {
206206
}
207207

208208
// init env variables
209+
flow.putEnv(FlowEnvs.FLOW_NAME, flowName);
209210
flow.putEnv(FlowEnvs.FLOW_STATUS, StatusValue.PENDING);
210211
flow.putEnv(FlowEnvs.FLOW_YML_STATUS, YmlStatusValue.NOT_FOUND);
211212
flow.putEnv(GitEnvs.FLOW_GIT_WEBHOOK, hooksUrl(flow));

platform-api/src/test/java/com/flow/platform/api/test/integration/GitWebhookTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ private Node init_flow(String gitUrl) throws Throwable {
306306
Node loaded = nodeService.find(flowPath).root();
307307

308308
Assert.assertNotNull(loaded);
309-
Assert.assertEquals(12, loaded.getEnvs().size());
309+
Assert.assertEquals(13, loaded.getEnvs().size());
310310
Assert.assertEquals(FlowEnvs.YmlStatusValue.FOUND.value(), loaded.getEnv(FlowEnvs.FLOW_YML_STATUS));
311311

312312
return loaded;

platform-api/src/test/java/com/flow/platform/api/test/service/EnvServiceTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ public void should_list_env() {
9494

9595
// then: check the flow actual envs size
9696
Node flow = nodeService.find(node.getPath()).root();
97-
Assert.assertEquals(10, flow.getEnvs().size());
97+
Assert.assertEquals(11, flow.getEnvs().size());
9898

9999
// when: list none editable only which from copied node envs
100100
Map<String, String> noneEditable = envService.list(node, false);
101-
Assert.assertEquals(8, noneEditable.size());
101+
Assert.assertEquals(9, noneEditable.size());
102102
Assert.assertTrue(noneEditable.containsKey(FLOW_STATUS.name()));
103103
Assert.assertTrue(noneEditable.containsKey(FLOW_YML_STATUS.name()));
104104
Assert.assertTrue(noneEditable.containsKey(FLOW_GIT_WEBHOOK.name()));
105105

106106
// then: check the actual flow envs size not changed
107-
Assert.assertEquals(10, flow.getEnvs().size());
107+
Assert.assertEquals(11, flow.getEnvs().size());
108108
}
109109
}

platform-api/src/test/java/com/flow/platform/api/test/service/NodeServiceTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ public void should_save_node_env() throws Throwable {
194194
// then:
195195
String webhook = HttpURL.build(apiDomain).append("/hooks/git").append(emptyFlow.getName()).toString();
196196
Node loaded = nodeService.find("flow1").root();
197-
Assert.assertEquals(15, loaded.getEnvs().size());
197+
Assert.assertEquals(16, loaded.getEnvs().size());
198+
Assert.assertEquals("flow1", loaded.getEnv(FlowEnvs.FLOW_NAME));
198199
Assert.assertEquals("hello", loaded.getEnv("FLOW_NEW_1"));
199200
Assert.assertEquals("world", loaded.getEnv("FLOW_NEW_2"));
200201
Assert.assertEquals("done", loaded.getEnv("FLOW_NEW_3"));
@@ -213,7 +214,7 @@ public void should_save_node_env() throws Throwable {
213214

214215
// check env been sync with yml
215216
Node flow = flowDao.get("flow1");
216-
Assert.assertEquals(15, flow.getEnvs().size());
217+
Assert.assertEquals(16, flow.getEnvs().size());
217218
Assert.assertEquals("hello", flow.getEnv("FLOW_NEW_1"));
218219
Assert.assertEquals("world", flow.getEnv("FLOW_NEW_2"));
219220
Assert.assertEquals("done", flow.getEnv("FLOW_NEW_3"));

0 commit comments

Comments
 (0)