Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit c0680e3

Browse files
author
Nikhil Bhoski
committed
Verifying if workspace exists for runMATLABCommand step
1 parent a62b9cc commit c0680e3

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

src/main/java/com/mathworks/ci/MatlabStepExecution.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ public boolean start() throws Exception {
3838
final TaskListener listener = getContext().get(TaskListener.class);
3939
final EnvVars env = getContext().get(EnvVars.class);
4040

41+
//Make sure the Workspace exists before run
42+
43+
workspace.mkdirs();
44+
4145
int res = execMatlabCommand(workspace, launcher, listener, env);
4246

4347
getContext().setResult((res == 0) ? Result.SUCCESS : Result.FAILURE);

src/test/java/com/mathworks/ci/RunMatlabCommandStepTest.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ public void testSetup() throws IOException {
3838
@Test
3939
public void verifyMATLABPathNotSet() throws Exception {
4040
project.setDefinition(
41-
new CpsFlowDefinition("node { writeFile text: 'worksapce', file: 'test.txt'\n"
42-
+ "runMATLABCommand(command: 'pwd')}", true));
41+
new CpsFlowDefinition("node { runMATLABCommand(command: 'pwd')}", true));
4342
WorkflowRun build = project.scheduleBuild2(0).get();
4443
j.assertLogContains("MATLAB_ROOT", build);
4544
}
@@ -52,8 +51,7 @@ public void verifyMATLABPathNotSet() throws Exception {
5251
@Test
5352
public void verifyMATLABPathSet() throws Exception {
5453
project.setDefinition(
55-
new CpsFlowDefinition("node { writeFile text: 'worksapce', file: 'test.txt'\n"
56-
+ "testMATLABCommand(command: 'pwd')}", true));
54+
new CpsFlowDefinition("node { testMATLABCommand(command: 'pwd')}", true));
5755
WorkflowRun build = project.scheduleBuild2(0).get();
5856
j.assertLogContains("tester_started", build);
5957
}
@@ -67,8 +65,7 @@ public void verifyMATLABPathSet() throws Exception {
6765
public void verifyPipelineOnSlave() throws Exception {
6866
DumbSlave s = j.createOnlineSlave();
6967
project.setDefinition(new CpsFlowDefinition(
70-
"node('!master') { writeFile text: 'worksapce', file: 'test.txt'\n"
71-
+ "testMATLABCommand(command: 'pwd')}",
68+
"node('!master') { testMATLABCommand(command: 'pwd')}",
7269
true));
7370

7471
s.getWorkspaceFor(project);
@@ -85,8 +82,7 @@ public void verifyPipelineOnSlave() throws Exception {
8582
@Test
8683
public void verifyCommandSameAsScript() throws Exception {
8784
project.setDefinition(
88-
new CpsFlowDefinition("node { writeFile text: 'worksapce', file: 'test.txt'\n"
89-
+ "runMATLABCommand(command: 'pwd')}", true));
85+
new CpsFlowDefinition("node { runMATLABCommand(command: 'pwd')}", true));
9086

9187
WorkflowRun build = project.scheduleBuild2(0).get();
9288
j.assertLogContains("pwd", build);
@@ -99,11 +95,10 @@ public void verifyCommandSameAsScript() throws Exception {
9995

10096
@Test
10197
public void verifyMatrixBuild() throws Exception {
102-
project.setDefinition(
103-
new CpsFlowDefinition("node { writeFile text: 'worksapce', file: 'test.txt'\n"
104-
+ "matrix {\n" + "agent any\n" + "axes {\n" + "axis {\n" + "name: 'CMD'\n"
105-
+ "values: 'pwd','ver'\n }}\n"
106-
+ "runMATLABCommand(command: '${CMD}')}}", true));
98+
project.setDefinition(new CpsFlowDefinition(
99+
"node { matrix {\n" + "agent any\n" + "axes {\n" + "axis {\n" + "name: 'CMD'\n"
100+
+ "values: 'pwd','ver'\n }}\n" + "runMATLABCommand(command: '${CMD}')}}",
101+
true));
107102

108103
WorkflowRun build = project.scheduleBuild2(0).get();
109104
j.assertLogContains("pwd", build);

0 commit comments

Comments
 (0)