Giter VIP home page Giter VIP logo

jenkins-matlab-plugin's Introduction

Continuous Integration with MATLAB on Jenkins

This plugin enables you to build and test your MATLAB® project as part of your Jenkins™ build. For example, you can automatically identify any code issues in your project, run tests and generate test and coverage artifacts, and package your files into a toolbox.

Releases

For a detailed list of releases, see Change Logs.

Configuration Steps

To configure the plugin, see Plugin Configuration Guide.

Examples

To learn how to use the plugin in testing workflows, see Examples.

Contact Us

If you have any questions or suggestions, please contact MathWorks® at [email protected].

License

MIT © 2019 The MathWorks, Inc.

Build Results

Overall
Build Status

jenkins-matlab-plugin's People

Contributors

abhargav-mw avatar acampbel avatar akarandi avatar davidbuzinski avatar dolonm-mw avatar hkhan17 avatar mw-hrastega avatar nbhoski avatar nikhilbhoski avatar ranford avatar sameagen-mw avatar tsharmamw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

jenkins-matlab-plugin's Issues

Pipeline support.

I see Pipeline support is 'todo'. Is there an estimation on that? Keeping the build process as part of the version controlled system is a great feature. It also makes it easy to tie pipeline code to requirements documents.

runMATLABCommand step has timeout of 5 minutes

Hello,

When using the runMATLABCommand step I experience two issues:

  • the runMATLABCommand step seems to have a timeout of 5 minutes.
  • when having a timeout on the runMATLABCommand step the job is not killed automatically. I need to perform a "hard kill"on Jenkins

Can you confirm these observations? I am running version 2.1.0 of the plugin.

Timeout of 5 minutes on runMATLABCommand step

To test this I have run the pipeline below. This will set the timeout to 10 minutes and runs a Matlab script which will pause for 6 minutes.

// Declarative Pipeline
pipeline {
    agent any
    options { timestamps() }
    stages {
        stage('test timing 2015'){
            environment {
        			PATH = "C:\\Program Files\\MATLAB\\R2015b\\bin;${PATH}"   // Windows agent
        	}
        	options {
                timeout(time: 10, unit: "MINUTES")
        	}
            steps {
                runMATLABCommand "pause(6*60); ver;pwd"
            } 
        }
    }
}

I expect the job to run for 6 minutes and print ver and pwd. However the job times out after 5 minutes. The Jenkins console shows:

11:41:37  Timeout set to expire in 10 min
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] runMATLABCommand
11:41:37  Generating MATLAB script with content:
11:41:37  pause(6*60); ver;pwd
11:41:37  
11:41:37  #################### Starting command output ####################
11:41:37  [d5354205-f476-4c03-b2ff-ac097c28ad0a] $ cmd.exe /C C:\Users\han\AppData\Local\Temp\\d5354205-f476-4c03-b2ff-ac097c28ad0a\run_matlab_command.bat "command_f0d95434_4742_42af_a7a3_76ed0ab5286f"
11:41:39   
11:41:39  To get started, type one of these: helpwin, helpdesk, or demo.
11:41:39  For product information, visit www.mathworks.com.
11:41:39   
11:41:40  Warning: Unable to locate a personal folder for $documents\MATLAB
11:41:40  Warning: Unable to locate a personal folder for $documents\MATLAB
11:46:37  ^CTerminate batch job (Y/N)? 
11:46:38  null

When replacing the runMATLABCommand step aby a bat-command the job will run for the requested 6 minutes:
bat "START /WAIT TIMEOUT /T 360 /NOBREAK >NUL"

Hard kill of the runMATLABCommand step

When decreasing the value for timeout in the pipeline to 1 minute the bat-job will stop after 1 minute:

11:52:42  Timeout set to expire in 1 min 0 sec
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] bat
11:52:43  
11:52:43  C:\Users\han\AppData\Local\Jenkins.jenkins\workspace\testen\testMatlab2007b@2>START /WAIT TIMEOUT /T 360 /NOBREAK  1>NUL 
11:53:42  Cancelling nested steps due to timeout
11:53:42  Sending interrupt signal to process

However I need to apply a 'hard kill' to kill the Matlab process. Please look at the attached console output:

11:48:14  Timeout set to expire in 1 min 0 sec
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] runMATLABCommand
11:48:14  Generating MATLAB script with content:
11:48:14  pause(6*60); ver;pwd
11:48:14  
11:48:14  #################### Starting command output ####################
11:48:14  [f66f0e2d-0297-44a8-86c9-c032eb6a395c] $ cmd.exe /C C:\Users\han\AppData\Local\Temp\\f66f0e2d-0297-44a8-86c9-c032eb6a395c\run_matlab_command.bat "command_6ee4aa6b_021f_4894_9c8f_1641da3c0c58"
11:48:16   
11:48:16  To get started, type one of these: helpwin, helpdesk, or demo.
11:48:16  For product information, visit www.mathworks.com.
11:48:16   
11:48:17  Warning: Unable to locate a personal folder for $documents\MATLAB
11:48:17  Warning: Unable to locate a personal folder for $documents\MATLAB
11:49:14  Cancelling nested steps due to timeout
11:50:14  Body did not finish within grace period; terminating with extreme prejudice
Aborted by Administrator
Aborted by Administrator
Click here to forcibly terminate running steps
Click here to forcibly terminate running steps
Aborted by Administrator
Click here to forcibly kill entire build
Hard kill!
Finished: ABORTED

kind regards, Han

Enable running tests in parallel in automatic mode.

I have my custom MATLAB script to enable other advanced options for test automation. One of those missing in automatic mode is running tests in parallel. It is easy to define this option with a checkbox in the UI and the following if-else statement.

% Run tests in parallel if required
if options.runInParallel
    results = runner.runInParallel(suite);
else
    results = runner.run(suite);
end

Screen Shots

image

image

image

image

image

image

##Use Custom MATLAB commands

image

image

image

image

image

Matrix Build Configuration

image

image

Generate Pipeline script in the workspace for every build

Is it possible to generate pipeline script in the workspace?

In case of a pipeline project, Jenkins creates workspace folder for every build. It would be nice to see the pipeline script that runs in the build. However, there are pipeline steps generated for the build. Could we use it to leverage?

Seeing this similar other CI services, where we have the YAML file for every build.

Remove "Unable to find MATLAB" warnings

Now that the plugin just calls whatever matlab command it finds on the system path, we should remove the "Unable to find MATLAB" warnings when you select to produce a test artifact.

Screen Shot 2020-04-01 at 8 55 28 AM

Pipeline syntax for matrix build generates error.

pipeline{
agent any
environment {
PATH = "$PATH:/Applications/MATLAB_${VERSION}.app/bin"
}
stages{
stage('checkout'){
steps
{
git credentialsId: '5f59e6e8-8b32-4c30-8461-bd17c2ac4fac', url: 'https://github.com/SangaviJayagopi/matlab-plugin-bash-repo'
}
}
stage('Build') {
matrix {
agent any
axes {
axis {
name 'VERSION'
values 'R2019a', 'R2019b', 'R2020a'
}
}
}
}
stage('Run MATLAB Command') {
steps
{
runMATLABCommand 'disp('hello')'
}
}
stage('Run MATLAB Tests'){
steps
{
runMATLABTests(
testResultsPDF:'test-results/results.pdf',
testResultsJUnit: 'test-results/results.xml',
testResultsTAP:'test-results/results.tap',
testResultsSimulinkTest:'test-results/results.mldatx',
codeCoverageCobertura: 'code-coverage/coverage.xml',
modelCoverageCobertura:'model-coverage/coverage.xml')
}
}

}

}

Console Output:

Started by user Sangavi Jayagopi
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 14: Missing required section "stages" @ line 14, column 13.
matrix {
^

1 error

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:327)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:427)

Finished: FAILURE

Added Simulink Test Reports in Automatic model

Thank you for automatic mode - great to have such an easy route to access CI
Would it be possible to add Simulink Test Rpeorts that are generated automatically to the results without having to go to the full custom mode?

Error/Warning messages for generating artifacts can be more specific

For example, PDF Report is not supported in Mac system is a known bug. The error messages(such as below) in Console log could be more specific. It can seem to be misleading to the user, as to what is missing with too many variables.

% Unable to produce PDF test reports. This problem might be due to a MATLAB release or operating system that does not support generating the specified artifact, a missing toolbox, or a missing license
runner = TestRunner.withTextOutput('Verbosity', Verbosity.Detailed);
% Unable to produce PDF test reports. This problem might be due to a MATLAB release or operating system that does not support generating the specified artifact, a missing toolbox, or a missing license.
runner.addPlugin(TAPPlugin.producingVersion13(ToFile('matlabTestArtifacts/taptestresults.tap')));
runner.addPlugin(XMLPlugin.producingJUnitFormat('matlabTestArtifacts/junittestresults.xml'));
% Unable to produce Simulink test results. This problem might be due to a MATLAB release or operating system that does not support generating the specified artifact, a missing toolbox, or a missing license.
runner.addPlugin(CodeCoveragePlugin.forFolder({'.'}, 'IncludingSubfolders', true, 'Producing', CoberturaFormat('matlabTestArtifacts/cobertura.xml')));
% Unable to produce Cobertura model coverage. This problem might be due to a MATLAB release or operating system that does not support generating the specified artifact, a missing toolbox, or a missing license.

Trouble to find tests in sub folders

Hello,

I'm actually using Matlab, Git Lab and Jenkins in order to have a CI environment for my Matlab projects. I usually have an architecture like this one where my test folder is a sub folder of a sub folder:
architecture

Before I found your plugin I was using a batch script who was running my runAllTests script using the same workflow as the script generated by your plugin. But the things is that the testsuite function generated can't find my tests .

Generated code

result in powershell

I'm not a Matlab pro but the only solution that a find at the moment is to change the testsuite function by using the TestSuite object of the Matlab framework.

Result in Powershell after changed

Code changes

This was by using the automatic configuration of the plugin. Actually, I'm forced to use the custom but, if this change won't brake anything , maybe it can be a better way to generate the script that run all the tests in a project.

Otherwise great job guys 💯

Yannis Ben Ouaghrem.

java.io.tmpdir returns \ at the end in Windows system

In my Windows 10, generated folder path contains two '\' marks after the temp folder like below:

[hello] $ cmd.exe /C C:\Users\myusername\AppData\Local\Temp\\651b1a37-8a22-4651-8a41-4019acfe5fbf\run_matlab_command.bat "exit(runMatlabTests())"

PDF test report generation throws error in MAC

The new "PDF test report" option in Jenkins MATLAB plugin throws error (when selected) in the console output in MAC platform.

Some observations:

a) In R2019a and below - Error gets thrown but build passes.
R2019a_error.docx

b) R2019b and above - Segmentation violation error and build fails.
R2020a_error.docx

c) It seems the error is thrown only with -batch and -r flags. I don't see any error when I run the script on MATLAB separately.

For version R2017a , R2017b build fails with error using eval

Build log:

Started by user Sangavi Jayagopi
Running as SYSTEM
Building on master in workspace /Users/sjayagop/.jenkins/workspace/test_genscript
using credential 5f59e6e8-8b32-4c30-8461-bd17c2ac4fac

git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/mathworks/ci-test-repo # timeout=10
Fetching upstream changes from https://github.com/mathworks/ci-test-repo
git --version # timeout=10
using GIT_ASKPASS to set credentials
git fetch --tags --force --progress -- https://github.com/mathworks/ci-test-repo +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse refs/remotes/origin/master^{commit} # timeout=10
git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 453bc666d454c957d0fa2aa8880245c0a4b96582 (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f 453bc666d454c957d0fa2aa8880245c0a4b96582 # timeout=10
Commit message: "Update startup.m"
git rev-list --no-walk 0704b14d1a27198cf2b027b85a1ef480d4589953 # timeout=10
[test_genscript] $ /var/folders/bc/l10_249126g1thr9hhsv2wj4000fnq/T/0a2785ff-9a9d-42e8-b4ee-0bbd8aa0fc0a/run_matlab_command.sh "addpath('/var/folders/bc/l10_249126g1thr9hhsv2wj4000fnq/T/0a2785ff-9a9d-42e8-b4ee-0bbd8aa0fc0a'); test_runner_0a2785ff_9a9d_42e8_b4ee_0bbd8aa0fc0a"

                        < M A T L A B (R) >
              Copyright 1984-2017 The MathWorks, Inc.
               R2017a (9.2.0.556344) 64-bit (maci64)
                           March 27, 2017

This is the .matlabrc
STARTUP FILE**
/Users/sjayagop/.jenkins/workspace/test_genscript/startup.m
Error using eval
Undefined function 'addpath' for input arguments of type 'char'.
Build step 'Run MATLAB Tests' changed build result to FAILURE
Finished: FAILURE

Text Input for artifacts such as: matlabTestArtifact's/taptestresults.tap causes build failure

Console log at the end of the build:

Started by user Sangavi Jayagopi
Running as SYSTEM
Building on master in workspace /Users/sjayagop/.jenkins/workspace/test_genscript
[test_genscript] $ /var/folders/bc/l10_249126g1thr9hhsv2wj4000fnq/T/f1193c2c-d422-4f89-94ee-850f2b0133d6/run_matlab_command.sh "addpath('/var/folders/bc/l10_249126g1thr9hhsv2wj4000fnq/T/f1193c2c-d422-4f89-94ee-850f2b0133d6'); test_runner_f1193c2c_d422_4f89_94ee_850f2b0133d6"
{�Error: File:
/private/var/folders/bc/l10_249126g1thr9hhsv2wj4000fnq/T/f1193c2c-d422-4f89-94ee-850f2b0133d6/test_runner_f1193c2c_d422_4f89_94ee_850f2b0133d6.m
Line: 1 Column: 326
Invalid expression. Check for missing multiplication operator, missing or
unbalanced delimiters, or other syntax error. To construct matrices, use
brackets instead of parentheses.
}�
Build step 'Run MATLAB Tests' changed build result to FAILURE
Finished: FAILURE

Increase verbosity level by default with Run MATLAB Tests mode

When using the Run MATLAB Tests mode the text output in the console is in my opinion too poor. For example, it does not provide any information about the current status or execution of different test cases. You only know which test folder is being executed, that means that for test suites with many different test cases, the console may not display new information for a long time.

The matlab.unittest.TestRunner.withTextOutput allows setting different levels for LoggingLevel and OutputDetail. I found out that OutputDetail = 3 provides a good trade-off between console text length and useful information. Please consider increasing the output detail so that the console display info about running and done of single test cases.

Custom build fails due to string issue

I am trying to set up a new custom build using the Matlab plugin and R2016a on Windows. Even when leaving the "Matlab command" field empty, the build fails when trying to execute
"C:\Program Files\MATLAB\R2016a\bin\matlab" -nosplash -nodesktop -noAppIcon -noDisplayDesktop -r 'try,eval(""),catch e,disp(getReport(e,'extended')),exit(1),end,exit' -wait -log

When running the same command with GUI as
"C:\Program Files\MATLAB\R2016a\bin\matlab" -r 'try,eval(""),catch e,disp(getReport(e,'extended')),exit(1),end,exit' -wait -log
Matlab throws an error

'try,eval(),catch
Error: String is not terminated properly.

In a Matrix project, if one version of MATLAB is not available, build fails incase run from Mac but build does not fail incase run from Windows

  1. Create a Multi-Config project on Jenkins on Mac and Windows
  2. Add user-defined axis and versions
  3. Add versions that is not in the system
    4.The build fails in Mac but not in Windows.

Please refer to logs here:

In case of Mac,

Started by user Sangavi Jayagopi
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /Users/sjayagop/.jenkins/workspace/test_pipeline_dsl
[Pipeline] {
[Pipeline] stage
[Pipeline] { (BuildAndTest)
[Pipeline] parallel
[Pipeline] { (Branch: Matrix - VERSION = 'R2019a')
[Pipeline] { (Branch: Matrix - VERSION = 'R2019b')
[Pipeline] stage
[Pipeline] { (Matrix - VERSION = 'R2019a')
[Pipeline] stage
[Pipeline] { (Matrix - VERSION = 'R2019b')
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] node
[Pipeline] node
Running on Jenkins in /Users/sjayagop/.jenkins/workspace/test_pipeline_dsl@2
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Run MATLAB Command)
[Pipeline] runMATLABCommand
[test_pipeline_dsl@2] $ /var/folders/bc/l10_249126g1thr9hhsv2wj4000fnq/T//13f5c350-30e5-4692-9f08-209620ee1a63/run_matlab_command.sh pwd

ans =

'/Users/sjayagop/.jenkins/workspace/test_pipeline_dsl@2'

[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
Running on Jenkins in /Users/sjayagop/.jenkins/workspace/test_pipeline_dsl@2
[Pipeline] // node
[Pipeline] {
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Run MATLAB Command)
[Pipeline] runMATLABCommand
[test_pipeline_dsl@2] $ /var/folders/bc/l10_249126g1thr9hhsv2wj4000fnq/T//c3b065c8-0265-496f-8271-bf61381e11be/run_matlab_command.sh pwd
'matlab' command not found. Please make sure MATLAB_ROOT/bin is on
the system path, where MATLAB_ROOT is the full path to your MATLAB
installation directory.
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: FAILURE

In case of windows:

Started by user sjayagop
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\test_pipeline_dsl
[Pipeline] {
[Pipeline] stage
[Pipeline] { (BuildAndTest)
[Pipeline] parallel
[Pipeline] { (Branch: Matrix - VERSION = 'R2018b')
[Pipeline] { (Branch: Matrix - VERSION = 'R2020a')
[Pipeline] stage
[Pipeline] { (Matrix - VERSION = 'R2018b')
[Pipeline] stage
[Pipeline] { (Matrix - VERSION = 'R2020a')
[Pipeline] withEnv
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] node
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\test_pipeline_dsl@2
[Pipeline] node
[Pipeline] {
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (scm checkout)
[Pipeline] git
Warning: CredentialId "5f59e6e8-8b32-4c30-8461-bd17c2ac4fac" could not be found.

git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/SangaviJayagopi/matlab-plugin-bash-repo # timeout=10
Fetching upstream changes from https://github.com/SangaviJayagopi/matlab-plugin-bash-repo
git --version # timeout=10
git fetch --tags --force --progress -- https://github.com/SangaviJayagopi/matlab-plugin-bash-repo +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
git rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision af10ff2a123a66b3666212537956239eff7f8b0e (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f af10ff2a123a66b3666212537956239eff7f8b0e # timeout=10
git branch -a -v --no-abbrev # timeout=10
git branch -D master # timeout=10
git checkout -b master af10ff2a123a66b3666212537956239eff7f8b0e # timeout=10
Commit message: "Create rightTriTest.m"
git rev-list --no-walk af10ff2a123a66b3666212537956239eff7f8b0e # timeout=10
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Run MATLAB commands)
[Pipeline] runMATLABCommand
[test_pipeline_dsl@2] $ cmd.exe /C C:\Users\sjayagop\AppData\Local\Temp\40a822de-e508-4e74-9440-03e32c8c5fe7\run_matlab_command.bat "ver"


MATLAB Version: 9.8.0.1323502 (R2020a)
MATLAB License Number: 40447121
Operating System: Microsoft Windows 10 Enterprise Version 10.0 (Build 18362)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

MATLAB Version 9.8 (R2020a)
Simulink Version 10.1 (R2020a)
LTE Toolbox Version 3.3 (R2020a)
MATLAB Coder Version 5.0 (R2020a)
MATLAB Compiler Version 8.0 (R2020a)
MATLAB Compiler SDK Version 6.8 (R2020a)
MATLAB Report Generator Version 5.8 (R2020a)
Mapping Toolbox Version 4.10 (R2020a)
Signal Processing Toolbox Version 8.4 (R2020a)
Simulink 3D Animation Version 9.0 (R2020a)
Simulink Check Version 4.5 (R2020a)
Simulink Code Inspector Version 3.6 (R2020a)
Simulink Coder Version 9.3 (R2020a)
Simulink Compiler Version 1.0 (R2020a)
Simulink Control Design Version 5.5 (R2020a)
Simulink Coverage Version 5.0 (R2020a)
Simulink Design Optimization Version 3.8 (R2020a)
Simulink Design Verifier Version 4.3 (R2020a)
Simulink Desktop Real-Time Version 5.10 (R2020a)
Simulink PLC Coder Version 3.2 (R2020a)
Simulink Real-Time Version 6.12 (R2020a)
Simulink Report Generator Version 5.8 (R2020a)
Simulink Requirements Version 1.5 (R2020a)
Simulink Test Version 3.2 (R2020a)
[Pipeline] runMATLABCommand
[test_pipeline_dsl@2] $ cmd.exe /C C:\Users\sjayagop\AppData\Local\Temp\e4774d86-752a-4f79-a434-8ddffdd224ef\run_matlab_command.bat "pwd"

ans =

'C:\Program Files (x86)\Jenkins\workspace\test_pipeline_dsl@2'

[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
Running on Jenkins in C:\Program Files (x86)\Jenkins\workspace\test_pipeline_dsl@2
[Pipeline] // node
[Pipeline] {
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (scm checkout)
[Pipeline] git
Warning: CredentialId "5f59e6e8-8b32-4c30-8461-bd17c2ac4fac" could not be found.

git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
git config remote.origin.url https://github.com/SangaviJayagopi/matlab-plugin-bash-repo # timeout=10
Fetching upstream changes from https://github.com/SangaviJayagopi/matlab-plugin-bash-repo
git --version # timeout=10
git fetch --tags --force --progress -- https://github.com/SangaviJayagopi/matlab-plugin-bash-repo +refs/heads/:refs/remotes/origin/ # timeout=10
git rev-parse "refs/remotes/origin/master^{commit}" # timeout=10
git rev-parse "refs/remotes/origin/origin/master^{commit}" # timeout=10
Checking out Revision af10ff2a123a66b3666212537956239eff7f8b0e (refs/remotes/origin/master)
git config core.sparsecheckout # timeout=10
git checkout -f af10ff2a123a66b3666212537956239eff7f8b0e # timeout=10
git branch -a -v --no-abbrev # timeout=10
git branch -D master # timeout=10
git checkout -b master af10ff2a123a66b3666212537956239eff7f8b0e # timeout=10
Commit message: "Create rightTriTest.m"
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Run MATLAB commands)
[Pipeline] runMATLABCommand
[test_pipeline_dsl@2] $ cmd.exe /C C:\Users\sjayagop\AppData\Local\Temp\6fd318f1-204a-4a75-b23b-25b41bd87c36\run_matlab_command.bat "ver"


MATLAB Version: 9.8.0.1323502 (R2020a)
MATLAB License Number: 40447121
Operating System: Microsoft Windows 10 Enterprise Version 10.0 (Build 18362)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode

MATLAB Version 9.8 (R2020a)
Simulink Version 10.1 (R2020a)
LTE Toolbox Version 3.3 (R2020a)
MATLAB Coder Version 5.0 (R2020a)
MATLAB Compiler Version 8.0 (R2020a)
MATLAB Compiler SDK Version 6.8 (R2020a)
MATLAB Report Generator Version 5.8 (R2020a)
Mapping Toolbox Version 4.10 (R2020a)
Signal Processing Toolbox Version 8.4 (R2020a)
Simulink 3D Animation Version 9.0 (R2020a)
Simulink Check Version 4.5 (R2020a)
Simulink Code Inspector Version 3.6 (R2020a)
Simulink Coder Version 9.3 (R2020a)
Simulink Compiler Version 1.0 (R2020a)
Simulink Control Design Version 5.5 (R2020a)
Simulink Coverage Version 5.0 (R2020a)
Simulink Design Optimization Version 3.8 (R2020a)
Simulink Design Verifier Version 4.3 (R2020a)
Simulink Desktop Real-Time Version 5.10 (R2020a)
Simulink PLC Coder Version 3.2 (R2020a)
Simulink Real-Time Version 6.12 (R2020a)
Simulink Report Generator Version 5.8 (R2020a)
Simulink Requirements Version 1.5 (R2020a)
Simulink Test Version 3.2 (R2020a)
[Pipeline] runMATLABCommand
[test_pipeline_dsl@2] $ cmd.exe /C C:\Users\sjayagop\AppData\Local\Temp\84455bee-8d4d-442b-bbd3-475d37aa041f\run_matlab_command.bat "pwd"

ans =

'C:\Program Files (x86)\Jenkins\workspace\test_pipeline_dsl@2'

[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

Error executing more than one step in the 'Run MATLAB Command' stage

pipeline {
agent any
environment {
PATH = "$PATH:/Applications/MATLAB_R2019a.app/bin"
}
stages{
stage('checkout'){
steps
{
git credentialsId: '5f59e6e8-8b32-4c30-8461-bd17c2ac4fac', url: 'https://github.com/SangaviJayagopi/matlab-plugin-bash-repo'
}
}
stage('Run MATLAB Command') {
steps
{
runMATLABCommand 'disp('hello')'
runMATLABCommand 'sim('model1_oneDay')'
// Also fails with both statements in 1 line
// runMATLABCommand 'disp('hello');sim('model1_oneDay')'
}
}
stage('Run MATLAB Tests'){
steps
{
runMATLABTests()
}
}

}                 

}

Console output:

Started by user Sangavi Jayagopi
Running in Durability level: MAX_SURVIVABILITY
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 16: Expected a symbol @ line 16, column 17.
runMATLABCommand 'disp('hello');sim('model1_oneDay')'
^

1 error

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:310)
at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1085)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:603)
at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:581)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:558)
at groovy.lang.GroovyClassLoader.doParseClass(GroovyClassLoader.java:298)
at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:268)
at groovy.lang.GroovyShell.parseClass(GroovyShell.java:688)
at groovy.lang.GroovyShell.parse(GroovyShell.java:700)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.doParse(CpsGroovyShell.java:142)
at org.jenkinsci.plugins.workflow.cps.CpsGroovyShell.reparse(CpsGroovyShell.java:127)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.parseScript(CpsFlowExecution.java:561)
at org.jenkinsci.plugins.workflow.cps.CpsFlowExecution.start(CpsFlowExecution.java:522)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:327)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:427)

Finished: FAILURE

startup.m file not executing when starting Matlab job

When the job workspace contains a startup.m file, this is not executed by default. In the previous version of the Jenkins plugin Matlab was started in the job workspace and when a startup.m was present this was executed.
With the current jenkins plugin Matlab will not start in the job workspace and will perform a change directory in the (generated) command file. So any startup.m file in the job workspaced is not executed auutomatically.

Right now as a workaround I am using the command sequence "startup;sl_refresh_customizations;".

I was wondering why this behaviour was changed, and whether breaking the startup-file was considered?

regards, Han Geerligs

Use a script for runMatlabTest instead of a function

With the integration of genscript into the plugin (#130), the runMatlabTest function does not do much other than pass through name-value pairs to genscript. By keeping runMatlabTest a function, we are required to pass user-provided values to it through the system shell (e.g. run_matlab_command runMatlabTest(USER_PROVIDED_VALUES)). These user provided values will be parsed by the system shell before they make it into the function. This parsing can and will introduce unexpected issues.

Instead of passing these user-provided values to a function, the plugin should write them directly into a templated script. Then we can call run_matlab_command on the script and not worry about the system shell parsing the user provided values.

The templated script would look something like this:

testScript = genscript('Test',...
   'PDFTestReport', ${PDF_TEST_REPORT},...
   'TAPTestResults', ${TAP_TEST_RESULTS},...
   'JUnitTestResults', ${JUNIT_TEST_RESULTS},...
   'SimulinkTestResults', ${SIMULINK_TEST_RESULTS},...
   'CoberturaCodeCoverage', ${COBERTURA_CODE_COVERAGE},...
   'CoberturaModelCoverage', ${COBERTURA_MODEL_COVERAGE});

disp('Running MATLAB script with contents:\n');
disp(testScript.Contents);
fprintf('___________________________________\n\n');
run(testScript);

Then the plugin will need to find/replace the template placeholders with appropriate values when writing it to disk.

the plug-in uses a R2016a onwards function

From the documentation I understood this plug-in would work in R2013a and newer, however when I use the automatic test mode script manually in R2013a, it fails with:

>> runMatlabTests(true,true,false)
Undefined function 'testsuite' for input arguments of type 'char'.

Error in runMatlabTests (line 15)
suite = testsuite(pwd,'IncludeSubfolders',true);

And indeed if I look at the doc, "testsuite" only exists from R2016a onwards. Maybe the automatic test mode is not designed to work with releases of R2015b and older?

It seems the plug-in does recognize the MATLAB version, because it does not allow selecting Cobertura code coverage for older than R2017b.

The command disp(" 'ABC`abc") gives an unexpected EOF

$ /var/folders/bc/l10_249126g1thr9hhsv2wj4000fnq/T//a8ee18a1-e189-4a0d-af11-65302b909129/run_matlab_command.sh 'disp(" 'ABC`abc")'
/Applications/MATLAB_R2019a.app/bin/matlab: eval: line 1734: unexpected EOF while looking for matching ``'
/Applications/MATLAB_R2019a.app/bin/matlab: eval: line 1735: syntax error: unexpected end of file
Build step 'Run MATLAB Command' changed build result to FAILURE
Finished: FAILURE

Option to filter test files or define root folder to search test files in automatic mode

As far as I know, automatic mode runs all the test files located in a project. However, I usually have two or more different test files for different purposes (demo, complete tests, regression tests, etc). I use a custom script to run in Jenkins only those tests located in a certain "regression_tests" folder, because I don't want to run everything.

It will be very helpful to filter which test files we want to run either using label filtering or defining the path to start searching for test files.

Possible null pointer dereference NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE

Maven Build FAILURE

[INFO] --- findbugs-maven-plugin:3.0.5:check (findbugs) @ matlab ---
[INFO] BugInstance size is 2
[INFO] Error size is 0
[INFO] Total bugs: 2
[INFO] Possible null pointer dereference in com.mathworks.ci.MatlabBuild.getFilePathForUniqueFolder(Launcher, String, FilePath) due to return value of called method [com.mathworks.ci.MatlabBuild, com.mathworks.ci.MatlabBuild] Dereferenced at MatlabBuild.java:[line 79]Known null at MatlabBuild.java:[line 78] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
[INFO] Possible null pointer dereference in com.mathworks.ci.MatlabBuild.getNodeSpecificTmpFolderPath(FilePath) due to return value of called method [com.mathworks.ci.MatlabBuild, com.mathworks.ci.MatlabBuild] Dereferenced at MatlabBuild.java:[line 90]Known null at MatlabBuild.java:[line 89] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
[INFO]

To see bug detail using the Findbugs GUI, use the following command "mvn findbugs:gui"

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 04:57 min
[INFO] Finished at: 2020-03-16T10:16:35-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:findbugs-maven-plugin:3.0.5:check (findbugs) on project matlab: failed with 2 bugs and 0 errors -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.