Skip to content

Commit 7cf0660

Browse files
author
Yang Guo
committed
fix not passing output env as input for next node step
1 parent 3046a4c commit 7cf0660

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,10 @@ private void run(Node node, Job job) {
296296
// pass job env to node
297297
EnvUtil.merge(job.getEnvs(), node.getEnvs(), false);
298298

299+
// pass root node output to current node
300+
NodeResult rootResult = nodeResultService.find(tree.root().getPath(), job.getId());
301+
EnvUtil.merge(rootResult.getOutputs(), node.getEnvs(), false);
302+
299303
// to run node with customized cmd id
300304
try {
301305
NodeResult nodeResult = nodeResultService.find(node.getPath(), job.getId());

platform-api/src/test/java/com/flow/platform/api/test/controller/CmdWebhookControllerTest.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@
2020
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
2121
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
2222

23-
import com.flow.platform.api.domain.job.JobStatus;
24-
import com.flow.platform.api.domain.node.Flow;
2523
import com.flow.platform.api.domain.job.Job;
26-
import com.flow.platform.api.domain.node.Node;
24+
import com.flow.platform.api.domain.job.JobStatus;
2725
import com.flow.platform.api.domain.job.NodeResult;
2826
import com.flow.platform.api.domain.job.NodeStatus;
27+
import com.flow.platform.api.domain.node.Flow;
28+
import com.flow.platform.api.domain.node.Node;
2929
import com.flow.platform.api.domain.node.Step;
3030
import com.flow.platform.api.test.TestBase;
31+
import com.flow.platform.api.util.EnvUtil;
3132
import com.flow.platform.domain.Cmd;
3233
import com.flow.platform.domain.CmdResult;
3334
import com.flow.platform.domain.CmdStatus;
3435
import com.flow.platform.domain.CmdType;
3536
import com.flow.platform.util.git.model.GitEventType;
3637
import com.flow.platform.util.http.HttpURL;
37-
import java.util.List;
3838
import org.junit.Assert;
3939
import org.junit.Before;
4040
import org.junit.Test;
@@ -103,6 +103,7 @@ public void should_callback_session_success() throws Throwable {
103103

104104
CmdResult cmdResult = new CmdResult(0);
105105
cmdResult.setDuration(100L);
106+
cmdResult.setOutput(EnvUtil.build("OUTPUT_ENV", "hello"));
106107
cmd.setCmdResult(cmdResult);
107108

108109
performMockHttpRequest(cmd, job);
@@ -112,9 +113,18 @@ public void should_callback_session_success() throws Throwable {
112113
job = reload(job);
113114
Assert.assertEquals(JobStatus.RUNNING, job.getStatus());
114115

116+
// check step 1 node result
115117
resultForStep1 = nodeResultService.find(step1.getPath(), job.getId());
116118
Assert.assertEquals(NodeStatus.SUCCESS, resultForStep1.getStatus());
117119
Assert.assertEquals(0, resultForStep1.getExitCode().intValue());
120+
Assert.assertEquals(1, resultForStep1.getOutputs().size());
121+
Assert.assertEquals("hello", resultForStep1.getOutputs().get("OUTPUT_ENV"));
122+
123+
// check root node result
124+
NodeResult rootNodeResult = nodeResultService.find(job.getNodePath(), job.getId());
125+
Assert.assertEquals(2, rootNodeResult.getOutputs().size());
126+
Assert.assertNotNull(rootNodeResult.getOutputs().get("FLOW_JOB_LOG_PATH"));
127+
Assert.assertEquals("hello", rootNodeResult.getOutputs().get("OUTPUT_ENV"));
118128

119129
resultForRoot = nodeResultService.find(job.getNodePath(), job.getId());
120130
Assert.assertEquals(NodeStatus.RUNNING, resultForRoot.getStatus());

0 commit comments

Comments
 (0)