11package com .mathworks .ci ;
22
3- /**
4- * Copyright 2019-2020 The MathWorks, Inc.
5- *
6- * MATLAB test run builder used to run all MATLAB & Simulink tests automatically and generate
7- * selected test artifacts.
8- *
9- */
10-
11-
12- import java .io .File ;
133import java .io .IOException ;
144import java .util .ArrayList ;
155import java .util .List ;
16- import java .util .function .Function ;
176import javax .annotation .Nonnull ;
187import org .apache .commons .io .FilenameUtils ;
198import org .jenkinsci .Symbol ;
209import org .kohsuke .stapler .DataBoundConstructor ;
2110import org .kohsuke .stapler .DataBoundSetter ;
22- import org .kohsuke .stapler .QueryParameter ;
2311import org .kohsuke .stapler .StaplerRequest ;
24- import com .mathworks .ci .UseMatlabVersionBuildWrapper .UseMatlabVersionDescriptor ;
2512import hudson .EnvVars ;
2613import hudson .Extension ;
2714import hudson .FilePath ;
3320import hudson .model .TaskListener ;
3421import hudson .tasks .BuildStepDescriptor ;
3522import hudson .tasks .Builder ;
36- import hudson .util .FormValidation ;
37- import jenkins .model .Jenkins ;
3823import jenkins .tasks .SimpleBuildStep ;
3924import net .sf .json .JSONObject ;
4025
@@ -202,8 +187,6 @@ private EnvVars getEnv() {
202187 @ Extension
203188 public static class RunMatlabTestsDescriptor extends BuildStepDescriptor <Builder > {
204189
205- MatlabReleaseInfo rel ;
206-
207190 // Overridden Method used to show the text under build dropdown
208191 @ Override
209192 public String getDisplayName () {
@@ -228,116 +211,6 @@ public boolean isApplicable(
228211 @ SuppressWarnings ("rawtypes" ) Class <? extends AbstractProject > jobtype ) {
229212 return true ;
230213 }
231-
232-
233- /*
234- * Validation for Test artifact generator checkBoxes
235- */
236-
237- // Get the MATLAB root entered in build wrapper descriptor
238-
239-
240-
241- public FormValidation doCheckCoberturaChkBxFilePath (@ QueryParameter String coberturaChkBxFilePath ) {
242- List <Function <String , FormValidation >> listOfCheckMethods =
243- new ArrayList <Function <String , FormValidation >>();
244- if (!coberturaChkBxFilePath .isEmpty ()) {
245- listOfCheckMethods .add (chkCoberturaSupport );
246- }
247- return FormValidationUtil .getFirstErrorOrWarning (listOfCheckMethods , getMatlabRoot ());
248- }
249-
250- Function <String , FormValidation > chkCoberturaSupport = (String matlabRoot ) -> {
251- FilePath matlabRootPath = new FilePath (new File (matlabRoot ));
252- rel = new MatlabReleaseInfo (matlabRootPath );
253- final MatrixPatternResolver resolver = new MatrixPatternResolver (matlabRoot );
254- if (!resolver .hasVariablePattern ()) {
255- try {
256- if (rel .verLessThan (
257- MatlabBuilderConstants .BASE_MATLAB_VERSION_COBERTURA_SUPPORT )) {
258- return FormValidation .warning (
259- Message .getValue ("Builder.matlab.cobertura.support.warning" ));
260- }
261- } catch (MatlabVersionNotFoundException e ) {
262- return FormValidation
263- .warning (Message .getValue ("Builder.invalid.matlab.root.warning" ));
264- }
265- }
266-
267-
268- return FormValidation .ok ();
269- };
270-
271- public FormValidation doCheckModelCoverageChkBxFilePath (
272- @ QueryParameter String modelCoverageChkBxFilePath ) {
273- List <Function <String , FormValidation >> listOfCheckMethods =
274- new ArrayList <Function <String , FormValidation >>();
275- if (!modelCoverageChkBxFilePath .isEmpty ()) {
276- listOfCheckMethods .add (chkModelCoverageSupport );
277- }
278- return FormValidationUtil .getFirstErrorOrWarning (listOfCheckMethods , getMatlabRoot ());
279- }
280-
281- Function <String , FormValidation > chkModelCoverageSupport = (String matlabRoot ) -> {
282- FilePath matlabRootPath = new FilePath (new File (matlabRoot ));
283- rel = new MatlabReleaseInfo (matlabRootPath );
284- final MatrixPatternResolver resolver = new MatrixPatternResolver (matlabRoot );
285- if (!resolver .hasVariablePattern ()) {
286- try {
287- if (rel .verLessThan (
288- MatlabBuilderConstants .BASE_MATLAB_VERSION_MODELCOVERAGE_SUPPORT )) {
289- return FormValidation .warning (
290- Message .getValue ("Builder.matlab.modelcoverage.support.warning" ));
291- }
292- } catch (MatlabVersionNotFoundException e ) {
293- return FormValidation
294- .warning (Message .getValue ("Builder.invalid.matlab.root.warning" ));
295- }
296- }
297-
298-
299- return FormValidation .ok ();
300- };
301-
302- public FormValidation doCheckStmResultsChkBxFilePath (@ QueryParameter String stmResultsChkBxFilePath ) {
303- List <Function <String , FormValidation >> listOfCheckMethods =
304- new ArrayList <Function <String , FormValidation >>();
305- if (!stmResultsChkBxFilePath .isEmpty ()) {
306- listOfCheckMethods .add (chkSTMResultsSupport );
307- }
308- return FormValidationUtil .getFirstErrorOrWarning (listOfCheckMethods , getMatlabRoot ());
309- }
310-
311- Function <String , FormValidation > chkSTMResultsSupport = (String matlabRoot ) -> {
312- FilePath matlabRootPath = new FilePath (new File (matlabRoot ));
313- rel = new MatlabReleaseInfo (matlabRootPath );
314- final MatrixPatternResolver resolver = new MatrixPatternResolver (matlabRoot );
315- if (!resolver .hasVariablePattern ()) {
316- try {
317- if (rel .verLessThan (
318- MatlabBuilderConstants .BASE_MATLAB_VERSION_EXPORTSTMRESULTS_SUPPORT )) {
319- return FormValidation .warning (Message
320- .getValue ("Builder.matlab.exportstmresults.support.warning" ));
321- }
322- } catch (MatlabVersionNotFoundException e ) {
323- return FormValidation
324- .warning (Message .getValue ("Builder.invalid.matlab.root.warning" ));
325- }
326- }
327- return FormValidation .ok ();
328- };
329-
330- // Method to get the MatlabRoot value from Build wrapper class.
331- public static String getMatlabRoot () {
332- try {
333- return Jenkins .getInstance ().getDescriptorByType (UseMatlabVersionDescriptor .class )
334- .getMatlabRootFolder ();
335- } catch (Exception e ) {
336- // For any exception during getMatlabRootFolder() operation, return matlabRoot as
337- // NULL.
338- return null ;
339- }
340- }
341214 }
342215
343216 @ Override
@@ -425,8 +298,8 @@ private void addInputArgs(String reportName, String reportPath) {
425298 * 7Csort:date/jenkinsci-dev/AFYHSG3NUEI/UsVJIKoE4B8J
426299 *
427300 */
428- public class PdfChkBx {
429- String pdfReportFilePath ;
301+ public static class PdfChkBx {
302+ private String pdfReportFilePath ;
430303
431304 @ DataBoundConstructor
432305 public PdfChkBx () {
@@ -443,8 +316,8 @@ public String getPdfReportFilePath() {
443316 }
444317 }
445318
446- public class TapChkBx {
447- String tapReportFilePath ;
319+ public static class TapChkBx {
320+ private String tapReportFilePath ;
448321
449322 @ DataBoundConstructor
450323 public TapChkBx () {
@@ -461,8 +334,8 @@ public String getTapReportFilePath() {
461334 }
462335 }
463336
464- public class JunitChkBx {
465- String junitReportFilePath ;
337+ public static class JunitChkBx {
338+ private String junitReportFilePath ;
466339
467340 @ DataBoundConstructor
468341 public JunitChkBx () {
@@ -479,8 +352,8 @@ public String getJunitReportFilePath() {
479352 }
480353 }
481354
482- public class CoberturaChkBx {
483- String coberturaReportFilePath ;
355+ public static class CoberturaChkBx {
356+ private String coberturaReportFilePath ;
484357
485358 @ DataBoundConstructor
486359 public CoberturaChkBx () {
@@ -497,8 +370,8 @@ public String getCoberturaReportFilePath() {
497370 }
498371 }
499372
500- public class StmResultsChkBx {
501- String stmResultsFilePath ;
373+ public static class StmResultsChkBx {
374+ private String stmResultsFilePath ;
502375
503376 @ DataBoundConstructor
504377 public StmResultsChkBx () {
@@ -515,8 +388,8 @@ public String getStmResultsFilePath() {
515388 }
516389 }
517390
518- public class ModelCovChkBx {
519- String modelCoverageFilePath ;
391+ public static class ModelCovChkBx {
392+ private String modelCoverageFilePath ;
520393
521394 @ DataBoundConstructor
522395 public ModelCovChkBx () {
0 commit comments