Skip to content

Commit ac64319

Browse files
authored
Add generateSummary option to control result summary generation (#49)
* add opt-out functionality * add help texts * update display and help texts
1 parent aa23b76 commit ac64319

34 files changed

Lines changed: 323 additions & 96 deletions

src/main/java/com/mathworks/ci/actions/MatlabAction.java

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.actions;
22

33
/**
4-
* Copyright 2024-2025, The MathWorks Inc.
4+
* Copyright 2024-26, The MathWorks Inc.
55
*/
66

77
import com.mathworks.ci.BuildArtifactAction;
@@ -38,22 +38,25 @@ public MatlabAction(MatlabCommandRunner runner, BuildConsoleAnnotator annotator)
3838
this.annotator = annotator;
3939
}
4040

41-
public void copyBuildPluginsToTemp() throws IOException, InterruptedException {
42-
// Copy BuildRunner plugins and override default plugins function
41+
public void copyPluginsToTemp(boolean generateSummary) throws IOException, InterruptedException {
4342
if(this.annotator != null) {
4443
runner.copyFileToTempFolder(MatlabBuilderConstants.DEFAULT_PLUGIN, MatlabBuilderConstants.DEFAULT_PLUGIN);
45-
runner.copyFileToTempFolder(MatlabBuilderConstants.BUILD_REPORT_PLUGIN, MatlabBuilderConstants.BUILD_REPORT_PLUGIN);
46-
runner.copyFileToTempFolder(MatlabBuilderConstants.PAR_BUILD_REPORT_PLUGIN, MatlabBuilderConstants.PAR_BUILD_REPORT_PLUGIN);
4744
runner.copyFileToTempFolder(MatlabBuilderConstants.TASK_RUN_PROGRESS_PLUGIN, MatlabBuilderConstants.TASK_RUN_PROGRESS_PLUGIN);
45+
46+
if (generateSummary) {
47+
runner.copyFileToTempFolder(MatlabBuilderConstants.BUILD_REPORT_PLUGIN, MatlabBuilderConstants.BUILD_REPORT_PLUGIN);
48+
runner.copyFileToTempFolder(MatlabBuilderConstants.PAR_BUILD_REPORT_PLUGIN, MatlabBuilderConstants.PAR_BUILD_REPORT_PLUGIN);
49+
}
4850
}
4951

50-
// Copy TestRunner plugins and services
51-
runner.copyFileToTempFolder(MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN, MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN);
52-
runner.copyFileToTempFolder(MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN_SERVICE, MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN_SERVICE);
52+
// Copy TestRunner plugins and services (only for summary generation)
53+
if (generateSummary) {
54+
runner.copyFileToTempFolder(MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN, MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN);
55+
runner.copyFileToTempFolder(MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN_SERVICE, MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN_SERVICE);
56+
}
5357
}
5458

55-
public void setBuildEnvVars() throws IOException, InterruptedException {
56-
// Set environment variable
59+
public void setBuildEnvVars(boolean generateSummary) throws IOException, InterruptedException {
5760
runner.addEnvironmentVariable(
5861
"MW_MATLAB_TEMP_FOLDER",
5962
runner.getTempFolder().toString());
@@ -63,16 +66,21 @@ public void setBuildEnvVars() throws IOException, InterruptedException {
6366
runner.addEnvironmentVariable(
6467
"MW_MATLAB_BUILDTOOL_DEFAULT_PLUGINS_FCN_OVERRIDE",
6568
"ciplugins.jenkins.getDefaultPlugins");
69+
runner.addEnvironmentVariable(
70+
"MW_INPUT_GENERATE_SUMMARY",
71+
String.valueOf(generateSummary));
6672
}
6773
}
6874

6975
public void teardownAction(MatlabActionParameters params) {
70-
// Handle build result
71-
if(this.annotator != null) {
72-
moveBuildArtifactToBuildRoot(params);
73-
}
76+
if (params.getGenerateSummary()) {
77+
// Handle build result
78+
if (this.annotator != null) {
79+
moveBuildArtifactToBuildRoot(params);
80+
}
7481

75-
moveTestResultsToBuildRoot(params);
82+
moveTestResultsToBuildRoot(params);
83+
}
7684

7785
try {
7886
this.runner.removeTempFolder();

src/main/java/com/mathworks/ci/actions/RunMatlabBuildAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.actions;
22

33
/**
4-
* Copyright 2024-25, The MathWorks Inc.
4+
* Copyright 2024-26, The MathWorks Inc.
55
*/
66

77
import java.io.IOException;
@@ -29,8 +29,8 @@ public RunMatlabBuildAction(BuildActionParameters params) throws IOException, In
2929
}
3030

3131
public void run() throws IOException, InterruptedException, MatlabExecutionException {
32-
super.copyBuildPluginsToTemp();
33-
super.setBuildEnvVars();
32+
super.copyPluginsToTemp(this.params.getGenerateSummary());
33+
super.setBuildEnvVars(this.params.getGenerateSummary());
3434

3535
// Redirect output to the build annotator
3636
runner.redirectStdOut(annotator);

src/main/java/com/mathworks/ci/actions/RunMatlabCommandAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.actions;
22

33
/**
4-
* Copyright 2024-25, The MathWorks Inc.
4+
* Copyright 2024-26, The MathWorks Inc.
55
*/
66

77
import java.io.IOException;
@@ -29,8 +29,8 @@ public RunMatlabCommandAction(CommandActionParameters params) throws IOException
2929
}
3030

3131
public void run() throws IOException, InterruptedException, MatlabExecutionException {
32-
super.copyBuildPluginsToTemp();
33-
super.setBuildEnvVars();
32+
super.copyPluginsToTemp(this.params.getGenerateSummary());
33+
super.setBuildEnvVars(this.params.getGenerateSummary());
3434

3535
// Redirect output to the build annotator
3636
runner.redirectStdOut(annotator);

src/main/java/com/mathworks/ci/actions/RunMatlabTestsAction.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.actions;
22

33
/**
4-
* Copyright 2024-25, The MathWorks Inc.
4+
* Copyright 2024-26, The MathWorks Inc.
55
*/
66

77
import java.io.IOException;
@@ -29,6 +29,10 @@ public RunMatlabTestsAction(TestActionParameters params) throws IOException, Int
2929
}
3030

3131
public void run() throws IOException, InterruptedException, MatlabExecutionException {
32+
// No annotator in this action, so only test related plugins are copied here
33+
super.copyPluginsToTemp(this.params.getGenerateSummary());
34+
super.setBuildEnvVars(this.params.getGenerateSummary());
35+
3236
// Copy in genscript
3337
FilePath genScriptZip = runner.copyFileToTempFolder(
3438
MatlabBuilderConstants.MATLAB_SCRIPT_GENERATOR,

src/main/java/com/mathworks/ci/freestyle/RunMatlabBuildBuilder.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package com.mathworks.ci.freestyle;
22

33
/**
4-
* Copyright 2022-2024 The MathWorks, Inc.
4+
* Copyright 2022-26 The MathWorks, Inc.
55
*/
66

77
import java.io.IOException;
8+
import java.util.Optional;
89
import javax.annotation.Nonnull;
910
import org.kohsuke.stapler.DataBoundConstructor;
1011
import org.kohsuke.stapler.DataBoundSetter;
@@ -39,6 +40,7 @@ public class RunMatlabBuildBuilder extends Builder implements SimpleBuildStep {
3940
private String tasks;
4041
private StartupOptions startupOptions;
4142
private BuildOptions buildOptions;
43+
private Boolean generateSummary;
4244

4345
private MatlabActionFactory factory;
4446

@@ -67,6 +69,11 @@ public void setBuildOptions(BuildOptions buildOptions) {
6769
this.buildOptions = buildOptions;
6870
}
6971

72+
@DataBoundSetter
73+
public void setGenerateSummary(Boolean generateSummary) {
74+
this.generateSummary = generateSummary;
75+
}
76+
7077
public String getTasks() {
7178
return this.tasks;
7279
}
@@ -91,6 +98,10 @@ public String getBuildOptionsAsString() {
9198
: this.buildOptions.getOptions();
9299
}
93100

101+
public boolean getGenerateSummary() {
102+
return this.generateSummary == null || this.generateSummary;
103+
}
104+
94105
@Extension
95106
public static class RunMatlabBuildDescriptor extends BuildStepDescriptor<Builder> {
96107

@@ -139,7 +150,8 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
139150
build, workspace, env, launcher, listener,
140151
this.getStartupOptionsAsString(),
141152
this.getTasks(),
142-
this.getBuildOptionsAsString());
153+
this.getBuildOptionsAsString(),
154+
this.getGenerateSummary());
143155
RunMatlabBuildAction action = factory.createAction(params);
144156

145157
try {
@@ -152,6 +164,8 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
152164
// Added for backwards compatibility:
153165
// Called when object is loaded from persistent data.
154166
protected Object readResolve() {
167+
this.generateSummary = Optional.ofNullable(this.generateSummary).orElse(true);
168+
155169
if (factory == null) {
156170
factory = new MatlabActionFactory();
157171
}

src/main/java/com/mathworks/ci/freestyle/RunMatlabCommandBuilder.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
package com.mathworks.ci.freestyle;
22

33
/**
4-
* Copyright 2019-2024 The MathWorks, Inc.
4+
* Copyright 2019-26 The MathWorks, Inc.
55
*
66
* Script builder used to run custom MATLAB commands or scripts.
77
*/
88

99
import hudson.util.FormValidation;
1010
import java.io.IOException;
11+
import java.util.Optional;
1112
import javax.annotation.Nonnull;
1213
import jenkins.model.Jenkins;
1314
import org.kohsuke.stapler.DataBoundConstructor;
@@ -44,6 +45,7 @@ public class RunMatlabCommandBuilder extends Builder implements SimpleBuildStep
4445
// In use
4546
private String matlabCommand;
4647
private StartupOptions startupOptions;
48+
private Boolean generateSummary;
4749

4850
private MatlabActionFactory factory;
4951

@@ -67,6 +69,11 @@ public void setStartupOptions(StartupOptions startupOptions) {
6769
this.startupOptions = startupOptions;
6870
}
6971

72+
@DataBoundSetter
73+
public void setGenerateSummary(Boolean generateSummary) {
74+
this.generateSummary = generateSummary;
75+
}
76+
7077
public String getMatlabCommand() {
7178
return this.matlabCommand;
7279
}
@@ -81,6 +88,10 @@ public String getStartupOptionsAsString() {
8188
: this.startupOptions.getOptions();
8289
}
8390

91+
public boolean getGenerateSummary() {
92+
return this.generateSummary == null || this.generateSummary;
93+
}
94+
8495
@Extension
8596
public static class RunMatlabCommandDescriptor extends BuildStepDescriptor<Builder> {
8697

@@ -139,7 +150,8 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
139150
build, workspace, env,
140151
launcher, listener,
141152
getStartupOptionsAsString(),
142-
getMatlabCommand());
153+
getMatlabCommand(),
154+
getGenerateSummary());
143155
RunMatlabCommandAction action = factory.createAction(params);
144156

145157
try {
@@ -152,6 +164,8 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
152164
// Added for backwards compatibility:
153165
// Called when object is loaded from persistent data.
154166
protected Object readResolve() {
167+
this.generateSummary = Optional.ofNullable(this.generateSummary).orElse(true);
168+
155169
if (factory == null) {
156170
factory = new MatlabActionFactory();
157171
}

src/main/java/com/mathworks/ci/freestyle/RunMatlabTestsBuilder.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.freestyle;
22

33
/**
4-
* Copyright 2019-2024 The MathWorks, Inc.
4+
* Copyright 2019-26 The MathWorks, Inc.
55
*
66
* MATLAB test run builder used to run all MATLAB & Simulink tests automatically and generate
77
* selected test artifacts.
@@ -73,6 +73,7 @@ public class RunMatlabTestsBuilder extends Builder implements SimpleBuildStep {
7373
private String outputDetail = "default";
7474
private boolean useParallel = false;
7575
private boolean strict = false;
76+
private Boolean generateSummary;
7677

7778
private MatlabActionFactory factory;
7879

@@ -172,6 +173,11 @@ public void setStrict(boolean strict) {
172173
this.strict = strict;
173174
}
174175

176+
@DataBoundSetter
177+
public void setGenerateSummary(Boolean generateSummary) {
178+
this.generateSummary = generateSummary;
179+
}
180+
175181
public String getTapReportFilePath() {
176182
return this.getTapArtifact().getFilePath();
177183
}
@@ -297,6 +303,10 @@ public boolean getUseParallel() {
297303
return this.useParallel;
298304
}
299305

306+
public boolean getGenerateSummary() {
307+
return this.generateSummary == null || this.generateSummary;
308+
}
309+
300310
public StartupOptions getStartupOptions() {
301311
return this.startupOptions;
302312
}
@@ -346,6 +356,8 @@ protected Object readResolve() {
346356
.orElseGet(() -> this.getArtifactObject(htmlModelCoverageChkBx,
347357
new HtmlModelCoverageArtifact("matlabTestArtifacts/htmlmodelcoverage")));
348358

359+
this.generateSummary = Optional.ofNullable(this.generateSummary).orElse(true);
360+
349361
if (factory == null) {
350362
factory = new MatlabActionFactory();
351363
}
@@ -469,6 +481,7 @@ public void perform(@Nonnull Run<?, ?> build, @Nonnull FilePath workspace,
469481
this.getOutputDetail(),
470482
this.getUseParallel(),
471483
this.getStrict(),
484+
this.getGenerateSummary(),
472485
this.getSourceFolderPaths(),
473486
this.getSelectByFolderPaths());
474487
RunMatlabTestsAction action = factory.createAction(params);

src/main/java/com/mathworks/ci/parameters/BuildActionParameters.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.parameters;
22

33
/**
4-
* Copyright 2024 The MathWorks, Inc.
4+
* Copyright 2024-26 The MathWorks, Inc.
55
*/
66

77
import java.io.IOException;
@@ -16,16 +16,17 @@ public class BuildActionParameters extends MatlabActionParameters {
1616
private String tasks;
1717
private String buildOptions;
1818

19-
public BuildActionParameters(StepContext context, String startupOpts, String tasks, String buildOpts)
20-
throws IOException, InterruptedException {
21-
super(context, startupOpts);
19+
public BuildActionParameters(StepContext context, String startupOpts, String tasks, String buildOpts,
20+
boolean generateSummary) throws IOException, InterruptedException {
21+
super(context, startupOpts, generateSummary);
2222
this.tasks = tasks;
2323
this.buildOptions = buildOpts;
2424
}
2525

2626
public BuildActionParameters(Run<?, ?> build, FilePath workspace, EnvVars env, Launcher launcher,
27-
TaskListener listener, String startupOpts, String tasks, String buildOptions) {
28-
super(build, workspace, env, launcher, listener, startupOpts);
27+
TaskListener listener, String startupOpts, String tasks, String buildOptions,
28+
boolean generateSummary) {
29+
super(build, workspace, env, launcher, listener, startupOpts, generateSummary);
2930
this.tasks = tasks;
3031
this.buildOptions = buildOptions;
3132
}

src/main/java/com/mathworks/ci/parameters/CommandActionParameters.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.mathworks.ci.parameters;
22

33
/**
4-
* Copyright 2024 The MathWorks, Inc.
4+
* Copyright 2024-26 The MathWorks, Inc.
55
*/
66

77
import java.io.IOException;
@@ -15,15 +15,15 @@
1515
public class CommandActionParameters extends MatlabActionParameters {
1616
private String command;
1717

18-
public CommandActionParameters(StepContext context, String startupOpts, String command)
19-
throws IOException, InterruptedException {
20-
super(context, startupOpts);
18+
public CommandActionParameters(StepContext context, String startupOpts, String command,
19+
boolean generateSummary) throws IOException, InterruptedException {
20+
super(context, startupOpts, generateSummary);
2121
this.command = command;
2222
}
2323

2424
public CommandActionParameters(Run<?, ?> build, FilePath workspace, EnvVars env, Launcher launcher,
25-
TaskListener listener, String startupOpts, String command) {
26-
super(build, workspace, env, launcher, listener, startupOpts);
25+
TaskListener listener, String startupOpts, String command, boolean generateSummary) {
26+
super(build, workspace, env, launcher, listener, startupOpts, generateSummary);
2727
this.command = command;
2828
}
2929

0 commit comments

Comments
 (0)