Skip to content
This repository was archived by the owner on Mar 27, 2025. It is now read-only.

Commit 80069f8

Browse files
authored
Update CONFIGDOC.md
1 parent 86113b2 commit 80069f8

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

CONFIGDOC.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ When you define an automated pipeline of tasks in Jenkins™, whether in the
1313
- [Use the runMATLABCommand Step](#use-the-runmatlabcommand-step)
1414
- [Use the runMATLABTests Step](#use-the-runmatlabtests-step)
1515
- [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)
1717
- [Use MATLAB as a Tool in Pipeline Project](#use-matlab-as-a-tool-in-pipeline-project)
1818

1919
## Configure Plugin in Web UI
@@ -323,7 +323,7 @@ pipeline {
323323
}
324324
```
325325

326-
## Register MATLAB as a Jenkins Tool
326+
## Register MATLAB as Jenkins Tool
327327
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.
328328

329329
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:
332332

333333
1) In your Jenkins interface, select **Manage Jenkins > Global Tool Configuration**. A new page opens where you can register different tools with Jenkins.
334334
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**.
336336
4) To confirm your choices, click **Save** at the bottom of the page.
337337

338338
For example, register MATLAB R2020b as a Jenkins tool on your Windows-based local agent.
@@ -374,23 +374,20 @@ pipeline {
374374
375375
```
376376

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.
378378

379379
```groovy
380380
// Scripted Pipeline
381381
node {
382382
def matlabver
383383
stage('Run MATLAB Command') {
384-
// Specify the matlabroot/bin folder for the desired MATLAB version
385384
matlabver = tool 'R2020b'
386385
if (isUnix()){
387-
matlabver = matlabver + "/bin" // Linux or macOS agent
386+
env.PATH = "${matlabver}/bin:${env.PATH}" // Linux or macOS agent
388387
}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
389+
}
390+
runMATLABCommand 'myscript'
394391
}
395392
}
396393
```

0 commit comments

Comments
 (0)