Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 23 additions & 15 deletions src/main/java/com/mathworks/ci/actions/MatlabAction.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mathworks.ci.actions;

/**
* Copyright 2024-2025, The MathWorks Inc.
* Copyright 2024-26, The MathWorks Inc.
*/

import com.mathworks.ci.BuildArtifactAction;
Expand Down Expand Up @@ -38,22 +38,25 @@ public MatlabAction(MatlabCommandRunner runner, BuildConsoleAnnotator annotator)
this.annotator = annotator;
}

public void copyBuildPluginsToTemp() throws IOException, InterruptedException {
// Copy BuildRunner plugins and override default plugins function
public void copyPluginsToTemp(boolean generateSummary) throws IOException, InterruptedException {
if(this.annotator != null) {
runner.copyFileToTempFolder(MatlabBuilderConstants.DEFAULT_PLUGIN, MatlabBuilderConstants.DEFAULT_PLUGIN);
runner.copyFileToTempFolder(MatlabBuilderConstants.BUILD_REPORT_PLUGIN, MatlabBuilderConstants.BUILD_REPORT_PLUGIN);
runner.copyFileToTempFolder(MatlabBuilderConstants.PAR_BUILD_REPORT_PLUGIN, MatlabBuilderConstants.PAR_BUILD_REPORT_PLUGIN);
runner.copyFileToTempFolder(MatlabBuilderConstants.TASK_RUN_PROGRESS_PLUGIN, MatlabBuilderConstants.TASK_RUN_PROGRESS_PLUGIN);

if (generateSummary) {
runner.copyFileToTempFolder(MatlabBuilderConstants.BUILD_REPORT_PLUGIN, MatlabBuilderConstants.BUILD_REPORT_PLUGIN);
runner.copyFileToTempFolder(MatlabBuilderConstants.PAR_BUILD_REPORT_PLUGIN, MatlabBuilderConstants.PAR_BUILD_REPORT_PLUGIN);
}
}

// Copy TestRunner plugins and services
runner.copyFileToTempFolder(MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN, MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN);
runner.copyFileToTempFolder(MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN_SERVICE, MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN_SERVICE);
// Copy TestRunner plugins and services (only for summary generation)
if (generateSummary) {
runner.copyFileToTempFolder(MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN, MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN);
runner.copyFileToTempFolder(MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN_SERVICE, MatlabBuilderConstants.TEST_RESULTS_VIEW_PLUGIN_SERVICE);
}
}

public void setBuildEnvVars() throws IOException, InterruptedException {
// Set environment variable
public void setBuildEnvVars(boolean generateSummary) throws IOException, InterruptedException {
runner.addEnvironmentVariable(
"MW_MATLAB_TEMP_FOLDER",
runner.getTempFolder().toString());
Expand All @@ -63,16 +66,21 @@ public void setBuildEnvVars() throws IOException, InterruptedException {
runner.addEnvironmentVariable(
"MW_MATLAB_BUILDTOOL_DEFAULT_PLUGINS_FCN_OVERRIDE",
"ciplugins.jenkins.getDefaultPlugins");
runner.addEnvironmentVariable(
"MW_INPUT_GENERATE_SUMMARY",
String.valueOf(generateSummary));
}
}

public void teardownAction(MatlabActionParameters params) {
// Handle build result
if(this.annotator != null) {
moveBuildArtifactToBuildRoot(params);
}
if (params.getGenerateSummary()) {
// Handle build result
if (this.annotator != null) {
moveBuildArtifactToBuildRoot(params);
}

moveTestResultsToBuildRoot(params);
moveTestResultsToBuildRoot(params);
}

try {
this.runner.removeTempFolder();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mathworks.ci.actions;

/**
* Copyright 2024-25, The MathWorks Inc.
* Copyright 2024-26, The MathWorks Inc.
*/

import java.io.IOException;
Expand Down Expand Up @@ -29,8 +29,8 @@ public RunMatlabBuildAction(BuildActionParameters params) throws IOException, In
}

public void run() throws IOException, InterruptedException, MatlabExecutionException {
super.copyBuildPluginsToTemp();
super.setBuildEnvVars();
super.copyPluginsToTemp(this.params.getGenerateSummary());
super.setBuildEnvVars(this.params.getGenerateSummary());

// Redirect output to the build annotator
runner.redirectStdOut(annotator);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mathworks.ci.actions;

/**
* Copyright 2024-25, The MathWorks Inc.
* Copyright 2024-26, The MathWorks Inc.
*/

import java.io.IOException;
Expand Down Expand Up @@ -29,8 +29,8 @@ public RunMatlabCommandAction(CommandActionParameters params) throws IOException
}

public void run() throws IOException, InterruptedException, MatlabExecutionException {
super.copyBuildPluginsToTemp();
super.setBuildEnvVars();
super.copyPluginsToTemp(this.params.getGenerateSummary());
super.setBuildEnvVars(this.params.getGenerateSummary());

// Redirect output to the build annotator
runner.redirectStdOut(annotator);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mathworks.ci.actions;

/**
* Copyright 2024-25, The MathWorks Inc.
* Copyright 2024-26, The MathWorks Inc.
*/

import java.io.IOException;
Expand Down Expand Up @@ -29,6 +29,10 @@ public RunMatlabTestsAction(TestActionParameters params) throws IOException, Int
}

public void run() throws IOException, InterruptedException, MatlabExecutionException {
// No annotator in this action, so only test related plugins are copied here
super.copyPluginsToTemp(this.params.getGenerateSummary());
super.setBuildEnvVars(this.params.getGenerateSummary());

// Copy in genscript
FilePath genScriptZip = runner.copyFileToTempFolder(
MatlabBuilderConstants.MATLAB_SCRIPT_GENERATOR,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.mathworks.ci.freestyle;

/**
* Copyright 2022-2024 The MathWorks, Inc.
* Copyright 2022-26 The MathWorks, Inc.
*/

import java.io.IOException;
import java.util.Optional;
import javax.annotation.Nonnull;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
Expand Down Expand Up @@ -39,6 +40,7 @@
private String tasks;
private StartupOptions startupOptions;
private BuildOptions buildOptions;
private Boolean generateSummary;

private MatlabActionFactory factory;

Expand Down Expand Up @@ -67,6 +69,11 @@
this.buildOptions = buildOptions;
}

@DataBoundSetter
public void setGenerateSummary(Boolean generateSummary) {
this.generateSummary = generateSummary;
}

public String getTasks() {
return this.tasks;
}
Expand All @@ -91,6 +98,10 @@
: this.buildOptions.getOptions();
}

public boolean getGenerateSummary() {
return this.generateSummary == null || this.generateSummary;

Check warning on line 102 in src/main/java/com/mathworks/ci/freestyle/RunMatlabBuildBuilder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 102 is only partially covered, one branch is missing
}

@Extension
public static class RunMatlabBuildDescriptor extends BuildStepDescriptor<Builder> {

Expand Down Expand Up @@ -139,7 +150,8 @@
build, workspace, env, launcher, listener,
this.getStartupOptionsAsString(),
this.getTasks(),
this.getBuildOptionsAsString());
this.getBuildOptionsAsString(),
this.getGenerateSummary());
RunMatlabBuildAction action = factory.createAction(params);

try {
Expand All @@ -152,6 +164,8 @@
// Added for backwards compatibility:
// Called when object is loaded from persistent data.
protected Object readResolve() {
this.generateSummary = Optional.ofNullable(this.generateSummary).orElse(true);

Check warning on line 167 in src/main/java/com/mathworks/ci/freestyle/RunMatlabBuildBuilder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 167 is not covered by tests

if (factory == null) {
factory = new MatlabActionFactory();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.mathworks.ci.freestyle;

/**
* Copyright 2019-2024 The MathWorks, Inc.
* Copyright 2019-26 The MathWorks, Inc.
*
* Script builder used to run custom MATLAB commands or scripts.
*/

import hudson.util.FormValidation;
import java.io.IOException;
import java.util.Optional;
import javax.annotation.Nonnull;
import jenkins.model.Jenkins;
import org.kohsuke.stapler.DataBoundConstructor;
Expand Down Expand Up @@ -44,6 +45,7 @@
// In use
private String matlabCommand;
private StartupOptions startupOptions;
private Boolean generateSummary;

private MatlabActionFactory factory;

Expand All @@ -67,6 +69,11 @@
this.startupOptions = startupOptions;
}

@DataBoundSetter
public void setGenerateSummary(Boolean generateSummary) {
this.generateSummary = generateSummary;
}

public String getMatlabCommand() {
return this.matlabCommand;
}
Expand All @@ -81,6 +88,10 @@
: this.startupOptions.getOptions();
}

public boolean getGenerateSummary() {
return this.generateSummary == null || this.generateSummary;

Check warning on line 92 in src/main/java/com/mathworks/ci/freestyle/RunMatlabCommandBuilder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 92 is only partially covered, one branch is missing
}

@Extension
public static class RunMatlabCommandDescriptor extends BuildStepDescriptor<Builder> {

Expand Down Expand Up @@ -139,7 +150,8 @@
build, workspace, env,
launcher, listener,
getStartupOptionsAsString(),
getMatlabCommand());
getMatlabCommand(),
getGenerateSummary());
RunMatlabCommandAction action = factory.createAction(params);

try {
Expand All @@ -152,6 +164,8 @@
// Added for backwards compatibility:
// Called when object is loaded from persistent data.
protected Object readResolve() {
this.generateSummary = Optional.ofNullable(this.generateSummary).orElse(true);

Check warning on line 167 in src/main/java/com/mathworks/ci/freestyle/RunMatlabCommandBuilder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 167 is not covered by tests

if (factory == null) {
factory = new MatlabActionFactory();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mathworks.ci.freestyle;

/**
* Copyright 2019-2024 The MathWorks, Inc.
* Copyright 2019-26 The MathWorks, Inc.
*
* MATLAB test run builder used to run all MATLAB & Simulink tests automatically and generate
* selected test artifacts.
Expand Down Expand Up @@ -73,6 +73,7 @@
private String outputDetail = "default";
private boolean useParallel = false;
private boolean strict = false;
private Boolean generateSummary;

private MatlabActionFactory factory;

Expand Down Expand Up @@ -172,6 +173,11 @@
this.strict = strict;
}

@DataBoundSetter
public void setGenerateSummary(Boolean generateSummary) {
this.generateSummary = generateSummary;
}

public String getTapReportFilePath() {
return this.getTapArtifact().getFilePath();
}
Expand Down Expand Up @@ -297,6 +303,10 @@
return this.useParallel;
}

public boolean getGenerateSummary() {
return this.generateSummary == null || this.generateSummary;

Check warning on line 307 in src/main/java/com/mathworks/ci/freestyle/RunMatlabTestsBuilder.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 307 is only partially covered, one branch is missing
}

public StartupOptions getStartupOptions() {
return this.startupOptions;
}
Expand Down Expand Up @@ -346,6 +356,8 @@
.orElseGet(() -> this.getArtifactObject(htmlModelCoverageChkBx,
new HtmlModelCoverageArtifact("matlabTestArtifacts/htmlmodelcoverage")));

this.generateSummary = Optional.ofNullable(this.generateSummary).orElse(true);

if (factory == null) {
factory = new MatlabActionFactory();
}
Expand Down Expand Up @@ -469,6 +481,7 @@
this.getOutputDetail(),
this.getUseParallel(),
this.getStrict(),
this.getGenerateSummary(),
this.getSourceFolderPaths(),
this.getSelectByFolderPaths());
RunMatlabTestsAction action = factory.createAction(params);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mathworks.ci.parameters;

/**
* Copyright 2024 The MathWorks, Inc.
* Copyright 2024-26 The MathWorks, Inc.
*/

import java.io.IOException;
Expand All @@ -16,16 +16,17 @@ public class BuildActionParameters extends MatlabActionParameters {
private String tasks;
private String buildOptions;

public BuildActionParameters(StepContext context, String startupOpts, String tasks, String buildOpts)
throws IOException, InterruptedException {
super(context, startupOpts);
public BuildActionParameters(StepContext context, String startupOpts, String tasks, String buildOpts,
boolean generateSummary) throws IOException, InterruptedException {
super(context, startupOpts, generateSummary);
this.tasks = tasks;
this.buildOptions = buildOpts;
}

public BuildActionParameters(Run<?, ?> build, FilePath workspace, EnvVars env, Launcher launcher,
TaskListener listener, String startupOpts, String tasks, String buildOptions) {
super(build, workspace, env, launcher, listener, startupOpts);
TaskListener listener, String startupOpts, String tasks, String buildOptions,
boolean generateSummary) {
super(build, workspace, env, launcher, listener, startupOpts, generateSummary);
this.tasks = tasks;
this.buildOptions = buildOptions;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mathworks.ci.parameters;

/**
* Copyright 2024 The MathWorks, Inc.
* Copyright 2024-26 The MathWorks, Inc.
*/

import java.io.IOException;
Expand All @@ -15,15 +15,15 @@
public class CommandActionParameters extends MatlabActionParameters {
private String command;

public CommandActionParameters(StepContext context, String startupOpts, String command)
throws IOException, InterruptedException {
super(context, startupOpts);
public CommandActionParameters(StepContext context, String startupOpts, String command,
boolean generateSummary) throws IOException, InterruptedException {
super(context, startupOpts, generateSummary);
this.command = command;
}

public CommandActionParameters(Run<?, ?> build, FilePath workspace, EnvVars env, Launcher launcher,
TaskListener listener, String startupOpts, String command) {
super(build, workspace, env, launcher, listener, startupOpts);
TaskListener listener, String startupOpts, String command, boolean generateSummary) {
super(build, workspace, env, launcher, listener, startupOpts, generateSummary);
this.command = command;
}

Expand Down
Loading
Loading