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
+8-11Lines changed: 8 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ When you define an automated pipeline of tasks in Jenkins™, whether in the
13
13
-[Use the runMATLABCommand Step](#use-the-runmatlabcommand-step)
14
14
-[Use the runMATLABTests Step](#use-the-runmatlabtests-step)
15
15
-[Use MATLAB in Matrix Build](#use-matlab-in-matrix-build)
16
-
-[Register MATLAB as a Jenkins Tool](#register-matlab-as-a-jenkins-tool)
16
+
-[Register MATLAB as Jenkins Tool](#register-matlab-as-jenkins-tool)
17
17
-[Use MATLAB as a Tool in Pipeline Project](#use-matlab-as-a-tool-in-pipeline-project)
18
18
19
19
## Configure Plugin in Web UI
@@ -323,7 +323,7 @@ pipeline {
323
323
}
324
324
```
325
325
326
-
## Register MATLAB as a Jenkins Tool
326
+
## Register MATLAB as Jenkins Tool
327
327
To run MATLAB code and Simulink models as part of your automated pipeline of tasks, Jenkins invokes MATLAB as an external program. When you configure your project, you can explicitly specify the MATLAB version that Jenkins should invoke by providing the path to the desired MATLAB root folder. For example, you can use an `environment` block in your `Jenkinsfile` to specify a MATLAB root folder for your Pipeline project.
328
328
329
329
Instead of specifying the path to the MATLAB root folder on a per project basis, you can register MATLAB as a Jenkins tool, which can then be accessed by any project you configure in Jenkins. To register your desired MATLAB version as a tool, you are required to specify its name and location on the build agent. Once you have registered MATLAB as a tool, you no longer need to specify its root folder path within a project. Jenkins only needs the tool name to access MATLAB.
@@ -332,7 +332,7 @@ To register MATLAB as a Jenkins tool:
332
332
333
333
1) In your Jenkins interface, select **Manage Jenkins > Global Tool Configuration**. A new page opens where you can register different tools with Jenkins.
334
334
2) In the **MATLAB** section of the **Global Tool Configuration** page, locate and click **Add MATLAB**. The section expands and enables you to specify the name and installation location of MATLAB.
335
-
3) specify the name for your desired MATLAB version in the **MATLAB Name** box, and enter the full path to the MATLAB root folder in the **MATLAB root** box. To register MATLAB as a tool, you are not required to select **Install automatically**.
335
+
3) specify the name for your desired MATLAB version in the **Name** box, and enter the full path to the MATLAB root folder in the **MATLAB root** box. To register MATLAB as a tool, you are not required to select **Install automatically**.
336
336
4) To confirm your choices, click **Save** at the bottom of the page.
337
337
338
338
For example, register MATLAB R2020b as a Jenkins tool on your Windows-based local agent.
@@ -374,23 +374,20 @@ pipeline {
374
374
375
375
```
376
376
377
-
If you define your Pipeline using Scripted Pipeline syntax, you need to prepend the path to the `bin` folder of the desired MATLAB version to the PATH environment variable. Use the `tool` keyword following by the name of the tool to retrieve the path to the MATLAB root folder. Then, construct the path to the `bin` folder, and use `withEnv` to prepend it to the PATH environment variable.
377
+
If you define your Pipeline using Scripted Pipeline syntax, use the `tool` keyword followed by the name of the tool to retrieve the path to the MATLAB root folder. Then, prepend the path to the `bin` folder of the desired MATLAB version to the PATH environment variable.
378
378
379
379
```groovy
380
380
// Scripted Pipeline
381
381
node {
382
382
def matlabver
383
383
stage('Run MATLAB Command') {
384
-
// Specify the matlabroot/bin folder for the desired MATLAB version
385
384
matlabver = tool 'R2020b'
386
385
if (isUnix()){
387
-
matlabver = matlabver + "/bin" // Linux or macOS agent
386
+
env.PATH = "${matlabver}/bin:${env.PATH}" // Linux or macOS agent
388
387
}else{
389
-
matlabver = matlabver + "\\bin" // Windows agent
390
-
}
391
-
withEnv(["PATH + MATLAB = $matlabver"]) { // Prepend matlabroot/bin to the PATH variable
392
-
runMATLABCommand 'myscript'
393
-
}
388
+
env.PATH = "${matlabver}\\bin;${env.PATH}" // Windows agent
0 commit comments