You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 27, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: CONFIGDOC.md
+43-34Lines changed: 43 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
When you define a [Jenkins™ Pipeline](https://www.jenkins.io/doc/book/pipeline/), whether in the web UI or with a [`Jenkinsfile`](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/), you can use the plugin to run your MATLAB® code or Simulink® models on Jenkins. This guide demonstrates how to configure the plugin and use it in freestyle, multi-configuration, and Pipeline projects.
1
+
When you define an automated pipeline of tasks in Jenkins™, whether in the web UI or with a [`Jenkinsfile`](https://www.jenkins.io/doc/book/pipeline/jenkinsfile/), you can use the plugin to run your MATLAB® code or Simulink® models. This guide demonstrates how to configure the plugin and use it in freestyle, multi-configuration, and Pipeline projects.
2
2
3
3
4
4
-[Configure Plugin in Web UI](#configure-plugin-in-web-ui)
@@ -10,8 +10,8 @@ When you define a [Jenkins™ Pipeline](https://www.jenkins.io/doc/book/pipe
10
10
-[Set Up Multi-Configuration Project](#set-up-multi-configuration-project)
11
11
-[Set Up Pipeline Project](#set-up-pipeline-project)
12
12
-[Add MATLAB to System Path](#add-matlab-to-system-path)
Select **Use MATLAB version** to specify the full path to the MATLAB root folder that should be used for the build. The information in the **MATLAB root** box enables the plugin to prepend MATLAB to the system PATH environment variable of the build agent.
26
27
@@ -30,9 +31,9 @@ If the build agent already has your desired MATLAB on the path, then you are not
When you set up the **Build** section of the project configuration window, the plugin provides you with the **Run MATLAB Command** and **Run MATLAB Tests** build steps.
@@ -44,21 +45,21 @@ The **Run MATLAB Command** build step enables you to specify MATLAB commands tai
44
45
45
46
If you specify more than one MATLAB command, use a comma or semicolon to separate the commands. The build fails if the execution of any command results in an error.
If you need to specify several MATLAB commands, consider writing a MATLAB script or function as part of your repository and executing this script or function instead.
50
52
51
53
Test artifacts are not autogenerated if you choose to run tests using this build step. You can generate your desired test artifacts by configuring the test runner in the script or function that you invoke from the **Command** box.
52
54
53
55
#### Run MATLAB Tests
54
-
This build step uses a default setting to run tests authored using the MATLAB Unit Testing Framework or Simulink Test™. If your source code is organized into files and folders within a MATLAB project, then the plugin includes any test files in the project that have been labeled as `Test`. If your code does not leverage a MATLAB project or uses a MATLAB release before R2019a, then the plugin includes all tests in the project workspace, including its subfolders.
56
+
This build step uses a default setting to run tests authored using the MATLAB Unit Testing Framework or Simulink Test™. If your source code is organized into files and folders within a MATLAB project, then the plugin includes any test files in the project that have been labeled as `Test`. If your code does not leverage a MATLAB project or uses a MATLAB release before R2019a, then the plugin includes all tests in the project workspace, including its subfolders.
55
57
56
-
The **Run MATLAB Tests** build step enables you to generate different types of test artifacts. To publish the test results, you can use these artifacts with other Jenkins plugins. By default, the plugin assigns a name to each selected artifact and stores it in the `matlabTestArtifacts` folder of the project workspace. You can override the default artifact name and location by specifying a path relative to the project folder in the **File path** box. (If you leave the text box empty, the plugin does not generate an artifact.)
With the **Run MATLAB Tests** build step, you can optionally specify the location of folders containing source code, relative to the project root folder. When you specify a folder in the **Folder path** box, the plugin adds the specified folder and its subfolders to the top of the MATLAB search path. You can specify more folders by clicking **Add Folder**. If you specify folders, MATLAB uses only the source code in the specified folders and their subfolders to generate a coverage report.
If you do not select any of the test artifact check boxes, the tests still run, and test failures fail the build.
62
+
The **Run MATLAB Tests** build step enables you to generate different types of test artifacts. To publish the test results, you can use these artifacts with other Jenkins plugins. By default, the plugin assigns a name to each selected artifact and stores it in the `matlabTestArtifacts` folder of the project workspace. You can override the default artifact name and location by specifying a path relative to the project folder in the **File path** box. If you leave the text box empty, the plugin does not generate an artifact. If you do not select any of the test artifact check boxes, the tests still run, and test failures fail the build.
62
63
63
64
The **Run MATLAB Tests** build step produces a MATLAB script file and uses it to run the tests and generate the test artifacts. The plugin writes the contents of this file to the build log. You can review the build log in **Console Output** to understand the testing workflow.
64
65
@@ -72,10 +73,11 @@ To configure the plugin for a freestyle project, specify the location where MATL
72
73
73
74
1) In the **Build Environment** section of the project configuration window, select **Use MATLAB version**. Then, enter the full path to the MATLAB root folder in the **MATLAB root** box. (You can skip this step if MATLAB has already been added to the path on the build agent.)
2) Add the required build steps in the **Build** section:
78
-
* If you add the [**Run MATLAB Tests**](#run-matlab-tests) build step, select check boxes for the artifacts to be generated in the project workspace.
80
+
* If you add the [**Run MATLAB Tests**](#run-matlab-tests) build step, specify the source code and the artifacts to be generated in the project workspace.
79
81
* If you add the [**Run MATLAB Command**](#run-matlab-command) build step, enter your commands in the **Command** box.
80
82
81
83
## Set Up Multi-Configuration Project
@@ -87,21 +89,25 @@ To configure the plugin for a multi-configuration project, specify the locations
87
89
88
90
1) Add a user-defined axis in the **Configuration Matrix** section to represent the MATLAB versions in the build. Specify the name of the axis in the **Name** box and its values in the **Values** box. Separate the values with a space. In this example, four MATLAB versions are specified to run the same set of tests.
You can define several axes in the **Configuration Matrix** section. For example, add the TEST_TAG axis specifying the possible test tags for a group of tests.
2) In the **Build Environment** section, select **Use MATLAB version** and then specify the locations where MATLAB is installed using the user-defined axis name. In this example, **$VERSION** in the **MATLAB root** box is replaced by one axis value per build iteration.
3) Add the required build steps in the **Build** section:
101
-
* If you add the [**Run MATLAB Tests**](#run-matlab-tests) build step, select check boxes for the artifacts to be generated in the project workspace.
106
+
* If you add the [**Run MATLAB Tests**](#run-matlab-tests) build step, specify the source code and the artifacts to be generated in the project workspace.
102
107
* If you add the [**Run MATLAB Command**](#run-matlab-command) build step, enter your commands in the **Command** box. You can use the user-defined axes to create your commands. For example:
* Both **$VAR** and **${VAR}** are valid formats for accessing the values of the user-defined axis **VAR**. On macOS platforms, the **${VAR}** format is recommended.
@@ -122,16 +128,16 @@ You also can define your Pipeline directly in the project configuration window.
122
128
### Add MATLAB to System Path
123
129
When Jenkins executes MATLAB-related steps in your Pipeline, it uses the first MATLAB version on the system path. If the PATH environment variable of the build agent does not include any MATLAB versions, you must update the variable with the MATLAB root folder that should be used for the build.
124
130
125
-
To update the system PATH environment variable using Declarative Pipeline syntax, use an `environment` block in your `Jenkinsfile`. For example, prepend MATLAB R2020a to the system PATH environment variable and use it to run your command.
131
+
To update the system PATH environment variable using Declarative Pipeline syntax, use an `environment` block in your `Jenkinsfile`. For example, prepend MATLAB R2020b to the system PATH environment variable and use it to run your command.
126
132
127
133
```groovy
128
134
// Declarative Pipeline
129
135
pipeline {
130
136
agent any
131
137
environment {
132
-
PATH = "C:\\Program Files\\MATLAB\\R2020a\\bin;${PATH}" // Windows agent
133
-
// PATH = "/usr/local/MATLAB/R2020a/bin:${PATH}" // Linux agent
Use the `runMATLABCommand` step in your Pipeline to run MATLAB scripts, functions, and statements tailored to your specific needs. You can use this task to flexibly customize your test run or run any MATLAB commands.
160
166
161
167
You must provide `runMATLABCommand` with a string that specifies the command you want to execute. If the command is the name of a MATLAB script or function, do not specify the file extension. If you specify more than one MATLAB command, use a comma or semicolon to separate the commands.
@@ -194,7 +200,7 @@ MATLAB exits with exit code 0 if the specified script, function, or statement ex
194
200
195
201
When you use the `runMATLABCommand` step, all of the required files must be on the MATLAB search path.
196
202
197
-
### Use `runMATLABTests` Step
203
+
### Use the runMATLABTests Step
198
204
199
205
Use the `runMATLABTests` step in your Pipeline to run all tests in your MATLAB project and generate artifacts. MATLAB includes any files in your project that have a `Test` label. If your Pipeline does not leverage a MATLAB project or uses a MATLAB release before R2019a, then MATLAB includes all tests in the the root of your repository, including its subfolders.
200
206
@@ -227,7 +233,7 @@ node {
227
233
228
234
To generate artifacts using the `runMATLABTests` step, provide the step with one or more name-value pair arguments to specify the artifacts and the locations to save them. Use a colon to separate names and values.
229
235
230
-
For example, define a Declarative Pipeline to run the tests in your MATLAB project, and then generate a JUnit test results report and a Cobertura code coverage report at specified locations on the build agent.
236
+
For example, define a Declarative Pipeline to run the tests in your MATLAB project, and then generate a JUnit test results report and a Cobertura code coverage report at specified locations on the build agent. Generate the coverage report for only the code in the `source` folder located in the root of your repository.
| testResultsSimulinkTest | Path to export Simulink Test Manager results in MLDATX format (requires Simulink Test license and is supported in MATLAB R2019a or later).<br/>**Example:**`'test-results/results.mldatx'`|
269
277
| codeCoverageCobertura | Path to write code coverage report in Cobertura XML format.<br/>**Example:**`'code-coverage/coverage.xml'`|
270
278
| modelCoverageCobertura | Path to write model coverage report in Cobertura XML format (requires Simulink Coverage™ license and is supported in MATLAB R2018b or later).<br/>**Example:**`'model-coverage/coverage.xml'`|
279
+
| sourceFolder | Locations of the folders containing source code, relative to the project root folder. The specified folders and their subfolders are added to the top of the MATLAB search path. To generate a coverage report, MATLAB uses only the source code in the specified folders and their subfolders. <br/>**Example:**`['source']`<br/>**Example:**`['src/folderA', 'src/folderB']`|
271
280
272
281
273
282
## Use MATLAB in Matrix Build
274
283
Similar to multi-configuration projects, you can use MATLAB as part of a [matrix](https://www.jenkins.io/doc/book/pipeline/syntax/#declarative-matrix) build in Pipeline projects. For example, you can define a Pipeline to run your test suite on different platforms or against different versions of MATLAB.
275
284
276
-
This example shows how to define a Declarative Pipeline to run your MATLAB code and generate test artifacts using MATLAB R2018b, R2019a, and R2020a. The Pipeline has a `matrix` section to define the possible name-value combinations that should run in parallel.
285
+
This example shows how to define a Declarative Pipeline to run your MATLAB code and generate test artifacts using MATLAB R2018b, R2019a, and R2020b. The Pipeline has a `matrix` section to define the possible name-value combinations that should run in parallel.
0 commit comments