From 9cef36deff686469cee59113573ea12e5925498e Mon Sep 17 00:00:00 2001 From: nbhoski Date: Wed, 12 Feb 2020 14:23:37 +0530 Subject: [PATCH 01/22] Added new Builders for script and test run. --- .../mathworks/ci/CommandConstructUtil.java | 140 ++++++++ .../com/mathworks/ci/MatlabBuildWrapper.java | 149 ++++++++ .../java/com/mathworks/ci/MatlabBuilder.java | 4 +- .../com/mathworks/ci/MatlabScriptBuilder.java | 5 + .../mathworks/ci/MatlabTestRunBuilder.java | 337 ++++++++++++++++++ 5 files changed, 634 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/mathworks/ci/CommandConstructUtil.java create mode 100644 src/main/java/com/mathworks/ci/MatlabBuildWrapper.java create mode 100644 src/main/java/com/mathworks/ci/MatlabScriptBuilder.java create mode 100644 src/main/java/com/mathworks/ci/MatlabTestRunBuilder.java diff --git a/src/main/java/com/mathworks/ci/CommandConstructUtil.java b/src/main/java/com/mathworks/ci/CommandConstructUtil.java new file mode 100644 index 00000000..e25e5ec0 --- /dev/null +++ b/src/main/java/com/mathworks/ci/CommandConstructUtil.java @@ -0,0 +1,140 @@ +package com.mathworks.ci; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang.ArrayUtils; +import hudson.FilePath; +import hudson.Launcher; + +public class CommandConstructUtil { + + private Launcher launcher; + private String matlabRoot; + + public Launcher getLauncher() { + return launcher; + } + + public void setLauncher(Launcher launcher) { + this.launcher = launcher; + } + + public String getMatlabRoot() { + return matlabRoot; + } + + public void setMatlabRoot(String matlabRoot) { + this.matlabRoot = matlabRoot; + } + + /* + * Constructor to accepts the current launcher instance of the build with two parameters + * launcher : Launcher associated with current build instance + * matlabRoot: Expanded string value of MATLAB root + */ + + public CommandConstructUtil(Launcher launcher,String matlabRoot) { + this.launcher = launcher; + this.matlabRoot = matlabRoot; + } + + public List constructBatchCommandForTestRun(String inputArguments) { + final String runCommand; + final List matlabDefaultArgs; + String matlabFunctionName = + FilenameUtils.removeExtension(Message.getValue(MatlabBuilderConstants.MATLAB_RUNNER_TARGET_FILE)); + runCommand = "exit(" + matlabFunctionName + "(" + + inputArguments + "))"; + matlabDefaultArgs = + Arrays.asList(getMatlabRoot() + getNodeSpecificFileSeperator() + "bin" + getNodeSpecificFileSeperator() + "matlab", + "-batch", runCommand); + return matlabDefaultArgs; + } + + public List constructBatchCommandForScriptRun(String customCommand){ + final List matlabDefaultArgs; + matlabDefaultArgs = + Arrays.asList(getMatlabRoot() + getNodeSpecificFileSeperator() + "bin" + getNodeSpecificFileSeperator() + "matlab", + "-batch", customCommand); + return matlabDefaultArgs; + } + + public List constructDefaultCommandForTestRun(String inputArguments) throws MatlabVersionNotFoundException { + final List matlabDefaultArgs = new ArrayList(); + Collections.addAll(matlabDefaultArgs, getPreRunnerSwitches()); + if (!getLauncher().isUnix()) { + matlabDefaultArgs.add("-noDisplayDesktop"); + } + Collections.addAll(matlabDefaultArgs, getRunnerSwitch(inputArguments)); + if (!!getLauncher().isUnix()) { + matlabDefaultArgs.add("-wait"); + } + Collections.addAll(matlabDefaultArgs, getPostRunnerSwitches()); + return matlabDefaultArgs; + } + + public List constructDefaultCommandForScriptRun(String CustomScript) throws MatlabVersionNotFoundException { + final List matlabDefaultArgs = new ArrayList(); + Collections.addAll(matlabDefaultArgs, getPreRunnerSwitches()); + if (!getLauncher().isUnix()) { + matlabDefaultArgs.add("-noDisplayDesktop"); + } + Collections.addAll(matlabDefaultArgs, getRunnerForScriptRun(CustomScript)); + if (!!getLauncher().isUnix()) { + matlabDefaultArgs.add("-wait"); + } + Collections.addAll(matlabDefaultArgs, getPostRunnerSwitches()); + return matlabDefaultArgs; + } + + + private String[] getPreRunnerSwitches() throws MatlabVersionNotFoundException { + FilePath nodeSpecificMatlabRoot = new FilePath(getLauncher().getChannel(),getMatlabRoot()); + MatlabReleaseInfo matlabRel =new MatlabReleaseInfo(nodeSpecificMatlabRoot); + String[] preRunnerSwitches = + {getMatlabRoot() + getNodeSpecificFileSeperator() + "bin" + getNodeSpecificFileSeperator() + "matlab", "-nosplash", + "-nodesktop"}; + if(!matlabRel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT)) { + preRunnerSwitches = (String[]) ArrayUtils.add(preRunnerSwitches, "-noAppIcon"); + } + return preRunnerSwitches; + } + + private String[] getPostRunnerSwitches() { + String[] postRunnerSwitch = {"-log"}; + return postRunnerSwitch; + } + + private String[] getRunnerSwitch(String inputArguments) { + final String runCommand; + String matlabFunctionName = + FilenameUtils.removeExtension(Message.getValue(MatlabBuilderConstants.MATLAB_RUNNER_TARGET_FILE)); + runCommand = "try,exit(" + matlabFunctionName + "(" + + inputArguments + + ")),catch e,disp(getReport(e,'extended')),exit(1),end"; + + final String[] runnerSwitch = {"-r", runCommand}; + return runnerSwitch; + } + + private String[] getRunnerForScriptRun(String customCommand) { + final String runCommand; + + runCommand = "try,eval('" + customCommand.replaceAll("'","''") + + "'),catch e,disp(getReport(e,'extended')),exit(1),end,exit"; + + final String[] runnerSwitch = {"-r", runCommand}; + return runnerSwitch; + } + + public String getNodeSpecificFileSeperator() { + if (getLauncher().isUnix()) { + return "/"; + } else { + return "\\"; + } + } +} diff --git a/src/main/java/com/mathworks/ci/MatlabBuildWrapper.java b/src/main/java/com/mathworks/ci/MatlabBuildWrapper.java new file mode 100644 index 00000000..6e76337b --- /dev/null +++ b/src/main/java/com/mathworks/ci/MatlabBuildWrapper.java @@ -0,0 +1,149 @@ +package com.mathworks.ci; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; +import org.kohsuke.stapler.QueryParameter; + +import hudson.EnvVars; +import hudson.Extension; +import hudson.FilePath; +import hudson.Launcher; +import hudson.model.AbstractProject; +import hudson.model.Run; +import hudson.model.TaskListener; +import hudson.tasks.BuildWrapperDescriptor; +import hudson.util.FormValidation; +import hudson.util.FormValidation.Kind; +import jenkins.tasks.SimpleBuildWrapper; + +public class MatlabBuildWrapper extends SimpleBuildWrapper { + + private String matlabRoot; + private EnvVars env; + + @DataBoundConstructor + public MatlabBuildWrapper() { + + } + + public String getMatlabRoot() { + return matlabRoot; + } + + @DataBoundSetter + public void setMatlabRoot(String matlabRoot) { + this.matlabRoot = matlabRoot; + } + + private String getLocalMatlab() { + return this.env == null ? getMatlabRoot(): this.env.expand(getMatlabRoot()); + } + + private void setEnv(EnvVars env) { + this.env = env; + } + + + @Extension + public static final class MatabBuildWrapperDescriptor extends BuildWrapperDescriptor { + + MatlabReleaseInfo rel; + String matlabRoot; + + public String getMatlabRoot() { + return matlabRoot; + } + + public void setMatlabRoot(String matlabRoot) { + this.matlabRoot = matlabRoot; + } + + @Override + public boolean isApplicable(AbstractProject item) { + return true; + } + + @Override + public String getDisplayName() { + return "With MATLAB"; + } + + public String getSelected() { + return this.matlabRoot; + } + + /* + * Below methods with 'doCheck' prefix gets called by jenkins when this builder is loaded. + * these methods are used to perform basic validation on UI elements associated with this + * descriptor class. + */ + + + public FormValidation doCheckMatlabRoot(@QueryParameter String matlabRoot) { + setMatlabRoot(matlabRoot); + List> listOfCheckMethods = + new ArrayList>(); + listOfCheckMethods.add(chkMatlabEmpty); + listOfCheckMethods.add(chkMatlabSupportsRunTests); + + return getFirstErrorOrWarning(listOfCheckMethods,matlabRoot); + } + + public FormValidation getFirstErrorOrWarning( + List> validations, String matlabRoot) { + if (validations == null || validations.isEmpty()) + return FormValidation.ok(); + for (Function val : validations) { + FormValidation validationResult = val.apply(matlabRoot); + if (validationResult.kind.compareTo(Kind.ERROR) == 0 + || validationResult.kind.compareTo(Kind.WARNING) == 0) { + return validationResult; + } + } + return FormValidation.ok(); + } + + Function chkMatlabEmpty = (String matlabRoot) -> { + if (matlabRoot.isEmpty()) { + return FormValidation.error(Message.getValue("Builder.matlab.root.empty.error")); + } + return FormValidation.ok(); + }; + + Function chkMatlabSupportsRunTests = (String matlabRoot) -> { + final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot); + if (!resolver.hasVariablePattern()) { + try { + FilePath matlabRootPath = new FilePath(new File(matlabRoot)); + rel = new MatlabReleaseInfo(matlabRootPath); + if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_RUNTESTS_SUPPORT)) { + return FormValidation + .error(Message.getValue("Builder.matlab.test.support.error")); + } + } catch (MatlabVersionNotFoundException e) { + return FormValidation + .warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + } + return FormValidation.ok(); + }; + } + + @Override + public void setUp(Context context, Run build, FilePath workspace, Launcher launcher, TaskListener listener, + EnvVars initialEnvironment) throws IOException, InterruptedException { + CommandConstructUtil utils = new CommandConstructUtil(launcher, getMatlabRoot()); + //Set Environment variable + + setEnv(initialEnvironment); + String nodeSpecificFileSep = utils.getNodeSpecificFileSeperator(); + context.env("matlabroot", getLocalMatlab()); + context.env("PATH+matlabroot", getLocalMatlab() + nodeSpecificFileSep + "bin"); + } +} diff --git a/src/main/java/com/mathworks/ci/MatlabBuilder.java b/src/main/java/com/mathworks/ci/MatlabBuilder.java index ab7e8855..66d79399 100644 --- a/src/main/java/com/mathworks/ci/MatlabBuilder.java +++ b/src/main/java/com/mathworks/ci/MatlabBuilder.java @@ -113,7 +113,9 @@ public void setMatlabRoot(String matlabRoot) { // Overridden Method used to show the text under build dropdown @Override public String getDisplayName() { - return Message.getBuilderDisplayName(); + // No name for this descriptor as its deprecated all the jobs will be + // automatically delegated to the new TestRun or Script builders. + return ""; } @Override diff --git a/src/main/java/com/mathworks/ci/MatlabScriptBuilder.java b/src/main/java/com/mathworks/ci/MatlabScriptBuilder.java new file mode 100644 index 00000000..337a1087 --- /dev/null +++ b/src/main/java/com/mathworks/ci/MatlabScriptBuilder.java @@ -0,0 +1,5 @@ +package com.mathworks.ci; + +public class MatlabScriptBuilder { + +} diff --git a/src/main/java/com/mathworks/ci/MatlabTestRunBuilder.java b/src/main/java/com/mathworks/ci/MatlabTestRunBuilder.java new file mode 100644 index 00000000..a011f2f6 --- /dev/null +++ b/src/main/java/com/mathworks/ci/MatlabTestRunBuilder.java @@ -0,0 +1,337 @@ +package com.mathworks.ci; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; +import javax.annotation.Nonnull; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; +import org.kohsuke.stapler.QueryParameter; +import org.kohsuke.stapler.StaplerRequest; +import com.mathworks.ci.MatlabBuildWrapper.MatabBuildWrapperDescriptor; +import hudson.EnvVars; +import hudson.Extension; +import hudson.FilePath; +import hudson.Launcher; +import hudson.Launcher.ProcStarter; +import hudson.model.AbstractProject; +import hudson.model.Result; +import hudson.model.Run; +import hudson.model.TaskListener; +import hudson.tasks.BuildStepDescriptor; +import hudson.tasks.Builder; +import hudson.util.FormValidation; +import hudson.util.FormValidation.Kind; +import jenkins.model.Jenkins; +import jenkins.tasks.SimpleBuildStep; +import net.sf.json.JSONObject; + +public class MatlabTestRunBuilder extends Builder implements SimpleBuildStep { + + private int buildResult; + private String matlabRoot; + private EnvVars env; + private MatlabReleaseInfo matlabRel; + private CommandConstructUtil utils; + private boolean tatapChkBx; + private boolean taJunitChkBx; + private boolean taCoberturaChkBx; + private boolean taSTMResultsChkBx; + private boolean taModelCoverageChkBx; + private boolean taPDFReportChkBx; + + @DataBoundConstructor + public MatlabTestRunBuilder() { + + + } + + + // Getter and Setters to access local members + + @DataBoundSetter + public void setMatlabRoot(String matlabRoot) { + this.matlabRoot = matlabRoot; + } + + @DataBoundSetter + public void setTatapChkBx(boolean tatapChkBx) { + this.tatapChkBx = tatapChkBx; + } + + @DataBoundSetter + public void setTaJunitChkBx(boolean taJunitChkBx) { + this.taJunitChkBx = taJunitChkBx; + } + + @DataBoundSetter + public void setTaCoberturaChkBx(boolean taCoberturaChkBx) { + this.taCoberturaChkBx = taCoberturaChkBx; + } + + @DataBoundSetter + public void setTaSTMResultsChkBx(boolean taSTMResultsChkBx) { + this.taSTMResultsChkBx = taSTMResultsChkBx; + } + + @DataBoundSetter + public void setTaModelCoverageChkBx(boolean taModelCoverageChkBx) { + this.taModelCoverageChkBx = taModelCoverageChkBx; + } + + @DataBoundSetter + public void setTaPDFReportChkBx(boolean taPDFReportChkBx) { + this.taPDFReportChkBx = taPDFReportChkBx; + } + + public boolean getTatapChkBx() { + return tatapChkBx; + } + + public boolean getTaJunitChkBx() { + return taJunitChkBx; + } + + public boolean getTaCoberturaChkBx() { + return taCoberturaChkBx; + } + + public boolean getTaSTMResultsChkBx() { + return taSTMResultsChkBx; + } + + public boolean getTaModelCoverageChkBx() { + return taModelCoverageChkBx; + } + + public boolean getTaPDFReportChkBx() { + return taPDFReportChkBx; + } + + public String getMatlabRoot() { + return this.matlabRoot; + } + + private void setEnv(EnvVars env) { + this.env = env; + } + + + @Extension + public static class MatlabTestDescriptor extends BuildStepDescriptor { + + + MatlabReleaseInfo rel; + + + // Overridden Method used to show the text under build dropdown + @Override + public String getDisplayName() { + return Message.getBuilderDisplayName(); + } + + @Override + public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { + save(); + return super.configure(req, formData); + } + + /* + * This is to identify which project type in jenkins this should be applicable.(non-Javadoc) + * + * @see hudson.tasks.BuildStepDescriptor#isApplicable(java.lang.Class) + * + * if it returns true then this build step will be applicable for all project type. + */ + @Override + public boolean isApplicable(@SuppressWarnings("rawtypes") Class jobtype) { + return true; + } + + + /* + * Validation for Test artifact generator checkBoxes + */ + + public FormValidation doCheckTaCoberturaChkBx(@QueryParameter boolean taCoberturaChkBx) { + List> listOfCheckMethods = + new ArrayList>(); + if (taCoberturaChkBx) { + listOfCheckMethods.add(chkCoberturaSupport); + } + return getFirstErrorOrWarning(listOfCheckMethods); + } + + Function chkCoberturaSupport = (String matlabRoot) -> { + FilePath matlabRootPath = new FilePath(new File(matlabRoot)); + rel = new MatlabReleaseInfo(matlabRootPath); + final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot); + if(!resolver.hasVariablePattern()) { + try { + if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_COBERTURA_SUPPORT)) { + return FormValidation + .warning(Message.getValue("Builder.matlab.cobertura.support.warning")); + } + } catch (MatlabVersionNotFoundException e) { + return FormValidation.warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + } + + + return FormValidation.ok(); + }; + + public FormValidation doCheckTaModelCoverageChkBx(@QueryParameter boolean taModelCoverageChkBx) { + List> listOfCheckMethods = + new ArrayList>(); + if (taModelCoverageChkBx) { + listOfCheckMethods.add(chkModelCoverageSupport); + } + return getFirstErrorOrWarning(listOfCheckMethods); + } + + Function chkModelCoverageSupport = (String matlabRoot) -> { + FilePath matlabRootPath = new FilePath(new File(matlabRoot)); + rel = new MatlabReleaseInfo(matlabRootPath); + final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot); + if(!resolver.hasVariablePattern()) { + try { + if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_MODELCOVERAGE_SUPPORT)) { + return FormValidation + .warning(Message.getValue("Builder.matlab.modelcoverage.support.warning")); + } + } catch (MatlabVersionNotFoundException e) { + return FormValidation.warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + } + + + return FormValidation.ok(); + }; + + public FormValidation doCheckTaSTMResultsChkBx(@QueryParameter boolean taSTMResultsChkBx) { + List> listOfCheckMethods = + new ArrayList>(); + if (taSTMResultsChkBx) { + listOfCheckMethods.add(chkSTMResultsSupport); + } + return getFirstErrorOrWarning(listOfCheckMethods); + } + + Function chkSTMResultsSupport = (String matlabRoot) -> { + FilePath matlabRootPath = new FilePath(new File(matlabRoot)); + rel = new MatlabReleaseInfo(matlabRootPath); + final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot); + if(!resolver.hasVariablePattern()) { + try { + if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_EXPORTSTMRESULTS_SUPPORT)) { + return FormValidation + .warning(Message.getValue("Builder.matlab.exportstmresults.support.warning")); + } + } catch (MatlabVersionNotFoundException e) { + return FormValidation.warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + } + + + return FormValidation.ok(); + }; + + public FormValidation getFirstErrorOrWarning( + List> validations) { + if (validations == null || validations.isEmpty()) + return FormValidation.ok(); + try { + final String matlabRoot = Jenkins.getInstance() + .getDescriptorByType(MatabBuildWrapperDescriptor.class).getMatlabRoot(); + for (Function val : validations) { + FormValidation validationResult = val.apply(matlabRoot); + if (validationResult.kind.compareTo(Kind.ERROR) == 0 + || validationResult.kind.compareTo(Kind.WARNING) == 0) { + return validationResult; + } + } + }catch (Exception e) { + return FormValidation.warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + + return FormValidation.ok(); + } + } + + @Override + public void perform(@Nonnull Run build, @Nonnull FilePath workspace, + @Nonnull Launcher launcher, @Nonnull TaskListener listener) + throws InterruptedException, IOException { + String matlabRoot = this.env.get("matlabroot"); + utils = new CommandConstructUtil(launcher, matlabRoot); + //Set the environment variable specific to the this build + setEnv(build.getEnvironment(listener)); + //Get node specific matlabroot to get matlab version information + FilePath nodeSpecificMatlabRoot = new FilePath(launcher.getChannel(),matlabRoot); + matlabRel = new MatlabReleaseInfo(nodeSpecificMatlabRoot); + + // Invoke MATLAB command and transfer output to standard + // Output Console + + buildResult = execMatlabCommand(workspace, launcher, listener); + + if (buildResult != 0) { + build.setResult(Result.FAILURE); + } + } + + private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher, + TaskListener listener) + throws IOException, InterruptedException { + ProcStarter matlabLauncher; + try { + matlabLauncher = launcher.launch().pwd(workspace).envs(this.env); + if (matlabRel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_BATCH_SUPPORT)) { + ListenerLogDecorator outStream = new ListenerLogDecorator(listener); + matlabLauncher = matlabLauncher.cmds(utils.constructDefaultCommandForTestRun(getInputArguments())).stderr(outStream); + } else { + matlabLauncher = matlabLauncher.cmds(utils.constructBatchCommandForTestRun(getInputArguments())).stdout(listener); + } + + // Copy MATLAB scratch file into the workspace. + FilePath targetWorkspace = new FilePath(launcher.getChannel(), workspace.getRemote()); + copyMatlabScratchFileInWorkspace(MatlabBuilderConstants.MATLAB_RUNNER_RESOURCE, MatlabBuilderConstants.MATLAB_RUNNER_TARGET_FILE, targetWorkspace); + } catch (Exception e) { + listener.getLogger().println(e.getMessage()); + return 1; + } + return matlabLauncher.join(); + } + + private void copyMatlabScratchFileInWorkspace(String matlabRunnerResourcePath, + String matlabRunnerTarget, FilePath targetWorkspace) + throws IOException, InterruptedException { + final ClassLoader classLoader = getClass().getClassLoader(); + FilePath targetFile = + new FilePath(targetWorkspace, Message.getValue(matlabRunnerTarget)); + InputStream in = classLoader.getResourceAsStream(matlabRunnerResourcePath); + + targetFile.copyFrom(in); + } + + // Concatenate the input arguments + private String getInputArguments() { + String pdfReport = MatlabBuilderConstants.PDF_REPORT + "," + this.getTaPDFReportChkBx(); + String tapResults = MatlabBuilderConstants.TAP_RESULTS + "," + this.getTatapChkBx(); + String junitResults = MatlabBuilderConstants.JUNIT_RESULTS + "," + this.getTaJunitChkBx(); + String stmResults = MatlabBuilderConstants.STM_RESULTS + "," + this.getTaSTMResultsChkBx(); + String coberturaCodeCoverage = MatlabBuilderConstants.COBERTURA_CODE_COVERAGE + "," + this.getTaCoberturaChkBx(); + String coberturaModelCoverage = MatlabBuilderConstants.COBERTURA_MODEL_COVERAGE + "," + this.getTaModelCoverageChkBx(); + + String inputArgsToMatlabFcn = pdfReport + "," + tapResults + "," + junitResults + "," + + stmResults + "," + coberturaCodeCoverage + "," + coberturaModelCoverage; + + return inputArgsToMatlabFcn; + } + + +} From 9c2bc9c106ae6f5c91d2556d1ccd80b860f616d5 Mon Sep 17 00:00:00 2001 From: nbhoski Date: Wed, 12 Feb 2020 14:23:37 +0530 Subject: [PATCH 02/22] Added new Builders for script and test run. --- .../mathworks/ci/CommandConstructUtil.java | 140 ++++++++ .../com/mathworks/ci/MatlabBuildWrapper.java | 149 ++++++++ .../java/com/mathworks/ci/MatlabBuilder.java | 4 +- .../com/mathworks/ci/MatlabScriptBuilder.java | 5 + .../mathworks/ci/MatlabTestRunBuilder.java | 337 ++++++++++++++++++ .../ci/MatlabBuildWrapper/config.jelly | 12 + .../ci/MatlabScriptBuilder/config.jelly | 8 + .../help-matlabCommand.html | 9 + .../ci/MatlabTestRunBuilder/config.jelly | 31 ++ .../help-coberturaChkBx.html | 5 + .../MatlabTestRunBuilder/help-junitChkBx.html | 5 + .../help-modelCoverageChkBx.html | 6 + .../help-pdfReportChkBx.html | 10 + .../help-stmResultsChkBx.html | 4 + .../MatlabTestRunBuilder/help-tapChkBx.html | 5 + .../ci/MatlabTestRunBuilder/runMatlabTests.m | 196 ++++++++++ 16 files changed, 925 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/mathworks/ci/CommandConstructUtil.java create mode 100644 src/main/java/com/mathworks/ci/MatlabBuildWrapper.java create mode 100644 src/main/java/com/mathworks/ci/MatlabScriptBuilder.java create mode 100644 src/main/java/com/mathworks/ci/MatlabTestRunBuilder.java create mode 100644 src/main/resources/com/mathworks/ci/MatlabBuildWrapper/config.jelly create mode 100644 src/main/resources/com/mathworks/ci/MatlabScriptBuilder/config.jelly create mode 100644 src/main/resources/com/mathworks/ci/MatlabScriptBuilder/help-matlabCommand.html create mode 100644 src/main/resources/com/mathworks/ci/MatlabTestRunBuilder/config.jelly create mode 100644 src/main/resources/com/mathworks/ci/MatlabTestRunBuilder/help-coberturaChkBx.html create mode 100644 src/main/resources/com/mathworks/ci/MatlabTestRunBuilder/help-junitChkBx.html create mode 100644 src/main/resources/com/mathworks/ci/MatlabTestRunBuilder/help-modelCoverageChkBx.html create mode 100644 src/main/resources/com/mathworks/ci/MatlabTestRunBuilder/help-pdfReportChkBx.html create mode 100644 src/main/resources/com/mathworks/ci/MatlabTestRunBuilder/help-stmResultsChkBx.html create mode 100644 src/main/resources/com/mathworks/ci/MatlabTestRunBuilder/help-tapChkBx.html create mode 100644 src/main/resources/com/mathworks/ci/MatlabTestRunBuilder/runMatlabTests.m diff --git a/src/main/java/com/mathworks/ci/CommandConstructUtil.java b/src/main/java/com/mathworks/ci/CommandConstructUtil.java new file mode 100644 index 00000000..e25e5ec0 --- /dev/null +++ b/src/main/java/com/mathworks/ci/CommandConstructUtil.java @@ -0,0 +1,140 @@ +package com.mathworks.ci; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import org.apache.commons.io.FilenameUtils; +import org.apache.commons.lang.ArrayUtils; +import hudson.FilePath; +import hudson.Launcher; + +public class CommandConstructUtil { + + private Launcher launcher; + private String matlabRoot; + + public Launcher getLauncher() { + return launcher; + } + + public void setLauncher(Launcher launcher) { + this.launcher = launcher; + } + + public String getMatlabRoot() { + return matlabRoot; + } + + public void setMatlabRoot(String matlabRoot) { + this.matlabRoot = matlabRoot; + } + + /* + * Constructor to accepts the current launcher instance of the build with two parameters + * launcher : Launcher associated with current build instance + * matlabRoot: Expanded string value of MATLAB root + */ + + public CommandConstructUtil(Launcher launcher,String matlabRoot) { + this.launcher = launcher; + this.matlabRoot = matlabRoot; + } + + public List constructBatchCommandForTestRun(String inputArguments) { + final String runCommand; + final List matlabDefaultArgs; + String matlabFunctionName = + FilenameUtils.removeExtension(Message.getValue(MatlabBuilderConstants.MATLAB_RUNNER_TARGET_FILE)); + runCommand = "exit(" + matlabFunctionName + "(" + + inputArguments + "))"; + matlabDefaultArgs = + Arrays.asList(getMatlabRoot() + getNodeSpecificFileSeperator() + "bin" + getNodeSpecificFileSeperator() + "matlab", + "-batch", runCommand); + return matlabDefaultArgs; + } + + public List constructBatchCommandForScriptRun(String customCommand){ + final List matlabDefaultArgs; + matlabDefaultArgs = + Arrays.asList(getMatlabRoot() + getNodeSpecificFileSeperator() + "bin" + getNodeSpecificFileSeperator() + "matlab", + "-batch", customCommand); + return matlabDefaultArgs; + } + + public List constructDefaultCommandForTestRun(String inputArguments) throws MatlabVersionNotFoundException { + final List matlabDefaultArgs = new ArrayList(); + Collections.addAll(matlabDefaultArgs, getPreRunnerSwitches()); + if (!getLauncher().isUnix()) { + matlabDefaultArgs.add("-noDisplayDesktop"); + } + Collections.addAll(matlabDefaultArgs, getRunnerSwitch(inputArguments)); + if (!!getLauncher().isUnix()) { + matlabDefaultArgs.add("-wait"); + } + Collections.addAll(matlabDefaultArgs, getPostRunnerSwitches()); + return matlabDefaultArgs; + } + + public List constructDefaultCommandForScriptRun(String CustomScript) throws MatlabVersionNotFoundException { + final List matlabDefaultArgs = new ArrayList(); + Collections.addAll(matlabDefaultArgs, getPreRunnerSwitches()); + if (!getLauncher().isUnix()) { + matlabDefaultArgs.add("-noDisplayDesktop"); + } + Collections.addAll(matlabDefaultArgs, getRunnerForScriptRun(CustomScript)); + if (!!getLauncher().isUnix()) { + matlabDefaultArgs.add("-wait"); + } + Collections.addAll(matlabDefaultArgs, getPostRunnerSwitches()); + return matlabDefaultArgs; + } + + + private String[] getPreRunnerSwitches() throws MatlabVersionNotFoundException { + FilePath nodeSpecificMatlabRoot = new FilePath(getLauncher().getChannel(),getMatlabRoot()); + MatlabReleaseInfo matlabRel =new MatlabReleaseInfo(nodeSpecificMatlabRoot); + String[] preRunnerSwitches = + {getMatlabRoot() + getNodeSpecificFileSeperator() + "bin" + getNodeSpecificFileSeperator() + "matlab", "-nosplash", + "-nodesktop"}; + if(!matlabRel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_NO_APP_ICON_SUPPORT)) { + preRunnerSwitches = (String[]) ArrayUtils.add(preRunnerSwitches, "-noAppIcon"); + } + return preRunnerSwitches; + } + + private String[] getPostRunnerSwitches() { + String[] postRunnerSwitch = {"-log"}; + return postRunnerSwitch; + } + + private String[] getRunnerSwitch(String inputArguments) { + final String runCommand; + String matlabFunctionName = + FilenameUtils.removeExtension(Message.getValue(MatlabBuilderConstants.MATLAB_RUNNER_TARGET_FILE)); + runCommand = "try,exit(" + matlabFunctionName + "(" + + inputArguments + + ")),catch e,disp(getReport(e,'extended')),exit(1),end"; + + final String[] runnerSwitch = {"-r", runCommand}; + return runnerSwitch; + } + + private String[] getRunnerForScriptRun(String customCommand) { + final String runCommand; + + runCommand = "try,eval('" + customCommand.replaceAll("'","''") + + "'),catch e,disp(getReport(e,'extended')),exit(1),end,exit"; + + final String[] runnerSwitch = {"-r", runCommand}; + return runnerSwitch; + } + + public String getNodeSpecificFileSeperator() { + if (getLauncher().isUnix()) { + return "/"; + } else { + return "\\"; + } + } +} diff --git a/src/main/java/com/mathworks/ci/MatlabBuildWrapper.java b/src/main/java/com/mathworks/ci/MatlabBuildWrapper.java new file mode 100644 index 00000000..6e76337b --- /dev/null +++ b/src/main/java/com/mathworks/ci/MatlabBuildWrapper.java @@ -0,0 +1,149 @@ +package com.mathworks.ci; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; + +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; +import org.kohsuke.stapler.QueryParameter; + +import hudson.EnvVars; +import hudson.Extension; +import hudson.FilePath; +import hudson.Launcher; +import hudson.model.AbstractProject; +import hudson.model.Run; +import hudson.model.TaskListener; +import hudson.tasks.BuildWrapperDescriptor; +import hudson.util.FormValidation; +import hudson.util.FormValidation.Kind; +import jenkins.tasks.SimpleBuildWrapper; + +public class MatlabBuildWrapper extends SimpleBuildWrapper { + + private String matlabRoot; + private EnvVars env; + + @DataBoundConstructor + public MatlabBuildWrapper() { + + } + + public String getMatlabRoot() { + return matlabRoot; + } + + @DataBoundSetter + public void setMatlabRoot(String matlabRoot) { + this.matlabRoot = matlabRoot; + } + + private String getLocalMatlab() { + return this.env == null ? getMatlabRoot(): this.env.expand(getMatlabRoot()); + } + + private void setEnv(EnvVars env) { + this.env = env; + } + + + @Extension + public static final class MatabBuildWrapperDescriptor extends BuildWrapperDescriptor { + + MatlabReleaseInfo rel; + String matlabRoot; + + public String getMatlabRoot() { + return matlabRoot; + } + + public void setMatlabRoot(String matlabRoot) { + this.matlabRoot = matlabRoot; + } + + @Override + public boolean isApplicable(AbstractProject item) { + return true; + } + + @Override + public String getDisplayName() { + return "With MATLAB"; + } + + public String getSelected() { + return this.matlabRoot; + } + + /* + * Below methods with 'doCheck' prefix gets called by jenkins when this builder is loaded. + * these methods are used to perform basic validation on UI elements associated with this + * descriptor class. + */ + + + public FormValidation doCheckMatlabRoot(@QueryParameter String matlabRoot) { + setMatlabRoot(matlabRoot); + List> listOfCheckMethods = + new ArrayList>(); + listOfCheckMethods.add(chkMatlabEmpty); + listOfCheckMethods.add(chkMatlabSupportsRunTests); + + return getFirstErrorOrWarning(listOfCheckMethods,matlabRoot); + } + + public FormValidation getFirstErrorOrWarning( + List> validations, String matlabRoot) { + if (validations == null || validations.isEmpty()) + return FormValidation.ok(); + for (Function val : validations) { + FormValidation validationResult = val.apply(matlabRoot); + if (validationResult.kind.compareTo(Kind.ERROR) == 0 + || validationResult.kind.compareTo(Kind.WARNING) == 0) { + return validationResult; + } + } + return FormValidation.ok(); + } + + Function chkMatlabEmpty = (String matlabRoot) -> { + if (matlabRoot.isEmpty()) { + return FormValidation.error(Message.getValue("Builder.matlab.root.empty.error")); + } + return FormValidation.ok(); + }; + + Function chkMatlabSupportsRunTests = (String matlabRoot) -> { + final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot); + if (!resolver.hasVariablePattern()) { + try { + FilePath matlabRootPath = new FilePath(new File(matlabRoot)); + rel = new MatlabReleaseInfo(matlabRootPath); + if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_RUNTESTS_SUPPORT)) { + return FormValidation + .error(Message.getValue("Builder.matlab.test.support.error")); + } + } catch (MatlabVersionNotFoundException e) { + return FormValidation + .warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + } + return FormValidation.ok(); + }; + } + + @Override + public void setUp(Context context, Run build, FilePath workspace, Launcher launcher, TaskListener listener, + EnvVars initialEnvironment) throws IOException, InterruptedException { + CommandConstructUtil utils = new CommandConstructUtil(launcher, getMatlabRoot()); + //Set Environment variable + + setEnv(initialEnvironment); + String nodeSpecificFileSep = utils.getNodeSpecificFileSeperator(); + context.env("matlabroot", getLocalMatlab()); + context.env("PATH+matlabroot", getLocalMatlab() + nodeSpecificFileSep + "bin"); + } +} diff --git a/src/main/java/com/mathworks/ci/MatlabBuilder.java b/src/main/java/com/mathworks/ci/MatlabBuilder.java index ab7e8855..66d79399 100644 --- a/src/main/java/com/mathworks/ci/MatlabBuilder.java +++ b/src/main/java/com/mathworks/ci/MatlabBuilder.java @@ -113,7 +113,9 @@ public void setMatlabRoot(String matlabRoot) { // Overridden Method used to show the text under build dropdown @Override public String getDisplayName() { - return Message.getBuilderDisplayName(); + // No name for this descriptor as its deprecated all the jobs will be + // automatically delegated to the new TestRun or Script builders. + return ""; } @Override diff --git a/src/main/java/com/mathworks/ci/MatlabScriptBuilder.java b/src/main/java/com/mathworks/ci/MatlabScriptBuilder.java new file mode 100644 index 00000000..337a1087 --- /dev/null +++ b/src/main/java/com/mathworks/ci/MatlabScriptBuilder.java @@ -0,0 +1,5 @@ +package com.mathworks.ci; + +public class MatlabScriptBuilder { + +} diff --git a/src/main/java/com/mathworks/ci/MatlabTestRunBuilder.java b/src/main/java/com/mathworks/ci/MatlabTestRunBuilder.java new file mode 100644 index 00000000..a011f2f6 --- /dev/null +++ b/src/main/java/com/mathworks/ci/MatlabTestRunBuilder.java @@ -0,0 +1,337 @@ +package com.mathworks.ci; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Function; +import javax.annotation.Nonnull; +import org.kohsuke.stapler.DataBoundConstructor; +import org.kohsuke.stapler.DataBoundSetter; +import org.kohsuke.stapler.QueryParameter; +import org.kohsuke.stapler.StaplerRequest; +import com.mathworks.ci.MatlabBuildWrapper.MatabBuildWrapperDescriptor; +import hudson.EnvVars; +import hudson.Extension; +import hudson.FilePath; +import hudson.Launcher; +import hudson.Launcher.ProcStarter; +import hudson.model.AbstractProject; +import hudson.model.Result; +import hudson.model.Run; +import hudson.model.TaskListener; +import hudson.tasks.BuildStepDescriptor; +import hudson.tasks.Builder; +import hudson.util.FormValidation; +import hudson.util.FormValidation.Kind; +import jenkins.model.Jenkins; +import jenkins.tasks.SimpleBuildStep; +import net.sf.json.JSONObject; + +public class MatlabTestRunBuilder extends Builder implements SimpleBuildStep { + + private int buildResult; + private String matlabRoot; + private EnvVars env; + private MatlabReleaseInfo matlabRel; + private CommandConstructUtil utils; + private boolean tatapChkBx; + private boolean taJunitChkBx; + private boolean taCoberturaChkBx; + private boolean taSTMResultsChkBx; + private boolean taModelCoverageChkBx; + private boolean taPDFReportChkBx; + + @DataBoundConstructor + public MatlabTestRunBuilder() { + + + } + + + // Getter and Setters to access local members + + @DataBoundSetter + public void setMatlabRoot(String matlabRoot) { + this.matlabRoot = matlabRoot; + } + + @DataBoundSetter + public void setTatapChkBx(boolean tatapChkBx) { + this.tatapChkBx = tatapChkBx; + } + + @DataBoundSetter + public void setTaJunitChkBx(boolean taJunitChkBx) { + this.taJunitChkBx = taJunitChkBx; + } + + @DataBoundSetter + public void setTaCoberturaChkBx(boolean taCoberturaChkBx) { + this.taCoberturaChkBx = taCoberturaChkBx; + } + + @DataBoundSetter + public void setTaSTMResultsChkBx(boolean taSTMResultsChkBx) { + this.taSTMResultsChkBx = taSTMResultsChkBx; + } + + @DataBoundSetter + public void setTaModelCoverageChkBx(boolean taModelCoverageChkBx) { + this.taModelCoverageChkBx = taModelCoverageChkBx; + } + + @DataBoundSetter + public void setTaPDFReportChkBx(boolean taPDFReportChkBx) { + this.taPDFReportChkBx = taPDFReportChkBx; + } + + public boolean getTatapChkBx() { + return tatapChkBx; + } + + public boolean getTaJunitChkBx() { + return taJunitChkBx; + } + + public boolean getTaCoberturaChkBx() { + return taCoberturaChkBx; + } + + public boolean getTaSTMResultsChkBx() { + return taSTMResultsChkBx; + } + + public boolean getTaModelCoverageChkBx() { + return taModelCoverageChkBx; + } + + public boolean getTaPDFReportChkBx() { + return taPDFReportChkBx; + } + + public String getMatlabRoot() { + return this.matlabRoot; + } + + private void setEnv(EnvVars env) { + this.env = env; + } + + + @Extension + public static class MatlabTestDescriptor extends BuildStepDescriptor { + + + MatlabReleaseInfo rel; + + + // Overridden Method used to show the text under build dropdown + @Override + public String getDisplayName() { + return Message.getBuilderDisplayName(); + } + + @Override + public boolean configure(StaplerRequest req, JSONObject formData) throws FormException { + save(); + return super.configure(req, formData); + } + + /* + * This is to identify which project type in jenkins this should be applicable.(non-Javadoc) + * + * @see hudson.tasks.BuildStepDescriptor#isApplicable(java.lang.Class) + * + * if it returns true then this build step will be applicable for all project type. + */ + @Override + public boolean isApplicable(@SuppressWarnings("rawtypes") Class jobtype) { + return true; + } + + + /* + * Validation for Test artifact generator checkBoxes + */ + + public FormValidation doCheckTaCoberturaChkBx(@QueryParameter boolean taCoberturaChkBx) { + List> listOfCheckMethods = + new ArrayList>(); + if (taCoberturaChkBx) { + listOfCheckMethods.add(chkCoberturaSupport); + } + return getFirstErrorOrWarning(listOfCheckMethods); + } + + Function chkCoberturaSupport = (String matlabRoot) -> { + FilePath matlabRootPath = new FilePath(new File(matlabRoot)); + rel = new MatlabReleaseInfo(matlabRootPath); + final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot); + if(!resolver.hasVariablePattern()) { + try { + if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_COBERTURA_SUPPORT)) { + return FormValidation + .warning(Message.getValue("Builder.matlab.cobertura.support.warning")); + } + } catch (MatlabVersionNotFoundException e) { + return FormValidation.warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + } + + + return FormValidation.ok(); + }; + + public FormValidation doCheckTaModelCoverageChkBx(@QueryParameter boolean taModelCoverageChkBx) { + List> listOfCheckMethods = + new ArrayList>(); + if (taModelCoverageChkBx) { + listOfCheckMethods.add(chkModelCoverageSupport); + } + return getFirstErrorOrWarning(listOfCheckMethods); + } + + Function chkModelCoverageSupport = (String matlabRoot) -> { + FilePath matlabRootPath = new FilePath(new File(matlabRoot)); + rel = new MatlabReleaseInfo(matlabRootPath); + final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot); + if(!resolver.hasVariablePattern()) { + try { + if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_MODELCOVERAGE_SUPPORT)) { + return FormValidation + .warning(Message.getValue("Builder.matlab.modelcoverage.support.warning")); + } + } catch (MatlabVersionNotFoundException e) { + return FormValidation.warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + } + + + return FormValidation.ok(); + }; + + public FormValidation doCheckTaSTMResultsChkBx(@QueryParameter boolean taSTMResultsChkBx) { + List> listOfCheckMethods = + new ArrayList>(); + if (taSTMResultsChkBx) { + listOfCheckMethods.add(chkSTMResultsSupport); + } + return getFirstErrorOrWarning(listOfCheckMethods); + } + + Function chkSTMResultsSupport = (String matlabRoot) -> { + FilePath matlabRootPath = new FilePath(new File(matlabRoot)); + rel = new MatlabReleaseInfo(matlabRootPath); + final MatrixPatternResolver resolver = new MatrixPatternResolver(matlabRoot); + if(!resolver.hasVariablePattern()) { + try { + if (rel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_EXPORTSTMRESULTS_SUPPORT)) { + return FormValidation + .warning(Message.getValue("Builder.matlab.exportstmresults.support.warning")); + } + } catch (MatlabVersionNotFoundException e) { + return FormValidation.warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + } + + + return FormValidation.ok(); + }; + + public FormValidation getFirstErrorOrWarning( + List> validations) { + if (validations == null || validations.isEmpty()) + return FormValidation.ok(); + try { + final String matlabRoot = Jenkins.getInstance() + .getDescriptorByType(MatabBuildWrapperDescriptor.class).getMatlabRoot(); + for (Function val : validations) { + FormValidation validationResult = val.apply(matlabRoot); + if (validationResult.kind.compareTo(Kind.ERROR) == 0 + || validationResult.kind.compareTo(Kind.WARNING) == 0) { + return validationResult; + } + } + }catch (Exception e) { + return FormValidation.warning(Message.getValue("Builder.invalid.matlab.root.warning")); + } + + return FormValidation.ok(); + } + } + + @Override + public void perform(@Nonnull Run build, @Nonnull FilePath workspace, + @Nonnull Launcher launcher, @Nonnull TaskListener listener) + throws InterruptedException, IOException { + String matlabRoot = this.env.get("matlabroot"); + utils = new CommandConstructUtil(launcher, matlabRoot); + //Set the environment variable specific to the this build + setEnv(build.getEnvironment(listener)); + //Get node specific matlabroot to get matlab version information + FilePath nodeSpecificMatlabRoot = new FilePath(launcher.getChannel(),matlabRoot); + matlabRel = new MatlabReleaseInfo(nodeSpecificMatlabRoot); + + // Invoke MATLAB command and transfer output to standard + // Output Console + + buildResult = execMatlabCommand(workspace, launcher, listener); + + if (buildResult != 0) { + build.setResult(Result.FAILURE); + } + } + + private synchronized int execMatlabCommand(FilePath workspace, Launcher launcher, + TaskListener listener) + throws IOException, InterruptedException { + ProcStarter matlabLauncher; + try { + matlabLauncher = launcher.launch().pwd(workspace).envs(this.env); + if (matlabRel.verLessThan(MatlabBuilderConstants.BASE_MATLAB_VERSION_BATCH_SUPPORT)) { + ListenerLogDecorator outStream = new ListenerLogDecorator(listener); + matlabLauncher = matlabLauncher.cmds(utils.constructDefaultCommandForTestRun(getInputArguments())).stderr(outStream); + } else { + matlabLauncher = matlabLauncher.cmds(utils.constructBatchCommandForTestRun(getInputArguments())).stdout(listener); + } + + // Copy MATLAB scratch file into the workspace. + FilePath targetWorkspace = new FilePath(launcher.getChannel(), workspace.getRemote()); + copyMatlabScratchFileInWorkspace(MatlabBuilderConstants.MATLAB_RUNNER_RESOURCE, MatlabBuilderConstants.MATLAB_RUNNER_TARGET_FILE, targetWorkspace); + } catch (Exception e) { + listener.getLogger().println(e.getMessage()); + return 1; + } + return matlabLauncher.join(); + } + + private void copyMatlabScratchFileInWorkspace(String matlabRunnerResourcePath, + String matlabRunnerTarget, FilePath targetWorkspace) + throws IOException, InterruptedException { + final ClassLoader classLoader = getClass().getClassLoader(); + FilePath targetFile = + new FilePath(targetWorkspace, Message.getValue(matlabRunnerTarget)); + InputStream in = classLoader.getResourceAsStream(matlabRunnerResourcePath); + + targetFile.copyFrom(in); + } + + // Concatenate the input arguments + private String getInputArguments() { + String pdfReport = MatlabBuilderConstants.PDF_REPORT + "," + this.getTaPDFReportChkBx(); + String tapResults = MatlabBuilderConstants.TAP_RESULTS + "," + this.getTatapChkBx(); + String junitResults = MatlabBuilderConstants.JUNIT_RESULTS + "," + this.getTaJunitChkBx(); + String stmResults = MatlabBuilderConstants.STM_RESULTS + "," + this.getTaSTMResultsChkBx(); + String coberturaCodeCoverage = MatlabBuilderConstants.COBERTURA_CODE_COVERAGE + "," + this.getTaCoberturaChkBx(); + String coberturaModelCoverage = MatlabBuilderConstants.COBERTURA_MODEL_COVERAGE + "," + this.getTaModelCoverageChkBx(); + + String inputArgsToMatlabFcn = pdfReport + "," + tapResults + "," + junitResults + "," + + stmResults + "," + coberturaCodeCoverage + "," + coberturaModelCoverage; + + return inputArgsToMatlabFcn; + } + + +} diff --git a/src/main/resources/com/mathworks/ci/MatlabBuildWrapper/config.jelly b/src/main/resources/com/mathworks/ci/MatlabBuildWrapper/config.jelly new file mode 100644 index 00000000..10e5137c --- /dev/null +++ b/src/main/resources/com/mathworks/ci/MatlabBuildWrapper/config.jelly @@ -0,0 +1,12 @@ + + + + This build step is depricated. Consider moving to the new MATLAB build steps. Current build however, will work with restricted access. + + + + + + +