This extension enables you to run MATLAB® scripts, functions, and statements as part of your build pipeline. You also can run your MATLAB and Simulink® tests, generate artifacts such as JUnit test results and Cobertura code coverage reports, and publish your results to Azure Pipelines.
To run your pipeline using the extension, install the extension to your Azure DevOps organization. (To install the extension, press the Get it free button at the top of this page.) You can use the extension with self-hosted or Linux®-based Microsoft®-hosted agents:
When you author your pipeline, the extension provides you with a task to run MATLAB scripts, functions, and statements. The extension also provides a task to run MATLAB and Simulink tests. Additionally, you can specify a Microsoft-hosted agent to run your MATLAB code.
Run MATLAB Script
Use the Run MATLAB Command task to run MATLAB scripts, functions, and statements tailored to your specific needs. You can use this task to flexibly customize your test run or add a build step to your pipeline.
For example, in a file named
Run Tests in MATLAB Project
Use the Run MATLAB Tests task to automatically run tests authored using the MATLAB Unit Testing Framework or Simulink Test™. You can use this task to generate different types of test artifacts. You can then publish the artifacts to Azure Pipelines.
For example, author a pipeline to run the tests in your MATLAB project automatically, and then generate a JUnit test results report and a Cobertura code coverage report at specified locations on the build agent. Use tasks to publish the generated artifacts to Azure Pipelines once the tests are executed. (The published artifacts are displayed in the Tests and Code Coverage tabs in the pipeline summary.)
Specify MATLAB in Pipeline
When you use the Run MATLAB Command or Run MATLAB Tests tasks in your pipeline, the self-hosted agent uses the first MATLAB version it encounters on the path. The job fails if the operating system cannot find MATLAB on the path.
You can prepend your desired version of MATLAB to the PATH environment variable of the agent. For example, prepend MATLAB R2020a to the path and use it to run your script.
Use MATLAB on Microsoft-Hosted Agent
Use the Install MATLAB task when you want to run MATLAB code in public projects that utilize Microsoft-hosted agents. The task installs the latest MATLAB release on a Linux virtual machine and enables the agent to run MATLAB scripts, functions, statements, and tests.
Use this task in conjunction with the Run MATLAB Command or Run MATLAB Tests tasks. For example, set up a Microsoft-hosted agent and use it to run the commands in your MATLAB script.
You can access the extension tasks and add them to your pipeline when you edit your pipeline in Azure DevOps.
Run MATLAB Command
Execute a MATLAB script, function, or statement. Specify the task in your pipeline YAML using the
MATLAB exits with exit code 0 if the specified script, function, or statement executes successfully without error. Otherwise, MATLAB terminates with a nonzero exit code, which causes the build to fail. You can use the
When you use this task, all of the required files must be on the MATLAB search path.
Run MATLAB Tests
Run all tests in a MATLAB project and generate test artifacts. Specify the task in your pipeline YAML using the
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 root of your repository including its subfolders.
Install the latest MATLAB release on a Linux-based Microsoft-hosted agent. Specify the task in your pipeline YAML using the
Currently, this task is available only for public projects and does not include transformation products, such as MATLAB Coder™ and MATLAB Compiler™.
If you have any questions or suggestions, please contact MathWorks® at firstname.lastname@example.org.