This extension enables you to build and test your MATLAB® project as part of your pipeline. 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. To run your pipeline using this extension, install the extension to your Azure® DevOps organization. To install the extension, click the To use a self-hosted agent, you must set up a computer with MATLAB as your self-hosted agent and register the agent with Azure Pipelines. The agent uses the topmost MATLAB version on the system path to execute your pipeline. To use a Microsoft-hosted agent, you must include a task in your pipeline to install MATLAB on the agent. Currently, this task is available only for public projects. It does not install transformation products, such as MATLAB Coder™ and MATLAB Compiler™.
## Usage ExamplesWhen you author your pipeline in a file named - To run a MATLAB build, use the Run MATLAB Build task.
- To run MATLAB and Simulink® tests and generate artifacts, use the Run MATLAB Tests task.
- To run a MATLAB script, function, or statement, use the Run MATLAB Command task.
- To install MATLAB on a Microsoft-hosted agent, use the Install MATLAB task.
## Run a MATLAB BuildUse the Run MATLAB Build task to run a build using the MATLAB build tool. You can use this task to run the MATLAB build tasks specified in a file named For example, author a pipeline to run a task named
## Run Tests in MATLAB ProjectUse the Run MATLAB Tests task to run tests authored using the MATLAB unit testing framework or Simulink Test™. You can use this task to generate various test and coverage 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 PDF test results report, 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 test run is complete.
You can access the artifacts in the pipeline summary window: - To download the PDF test results report, follow the
**published**link. - To view the JUnit test results report, open the
**Tests**tab. - To view the Cobertura code coverage report, open the
**Code Coverage**tab.
## Run MATLAB ScriptUse the Run MATLAB Command task to run MATLAB scripts, functions, and statements. You can use this task to flexibly customize your test run or add a step in MATLAB to your pipeline. For example, author a pipeline to run the commands in a file named
## Specify MATLAB in PipelineWhen you use the You can prepend your preferred version of MATLAB to the PATH environment variable of the agent. For example, prepend MATLAB R2022a to the path and use it to run your script.
## Use MATLAB on Microsoft-Hosted AgentBefore you run MATLAB code or Simulink models on a Microsoft-hosted agent, first use the Install MATLAB task. The task installs your specified MATLAB release (R2020a or later) on a Linux® virtual machine. If you do not specify a release, the task installs the latest release of MATLAB. For example, install MATLAB R2022a on a Microsoft-hosted agent, and then use the
## TasksYou can access the extension tasks and add them to your pipeline when you edit your pipeline in Azure DevOps. ## Run MATLAB BuildRun a build using the MATLAB build tool. Starting in R2022b, you can use this task to run the MATLAB build tasks specified in a file named
MATLAB exits with exit code 0 if the build runs successfully. Otherwise, MATLAB terminates with a nonzero exit code, which causes the pipeline to fail. When you use this task, a file named ## Run MATLAB TestsRun the tests in a MATLAB project and generate artifacts. Specify the task in your pipeline YAML using the By default, MATLAB includes any files in your project that have a The
## Run MATLAB CommandExecute 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 pipeline to fail. To fail the pipeline in certain conditions, use the When you use this task, all of the required files must be on the MATLAB search path. If your script or function is not in the root of your repository, you can use the
## Install MATLABInstall the specified MATLAB release on a Linux agent in the cloud. Specify the task in your pipeline YAML using the
Currently, this task is available only for public projects. It does not install transformation products, such as MATLAB Coder and MATLAB Compiler. ## Notes- The
**Run MATLAB Build**task uses the`-batch` option to invoke the`buildtool` command. In addition, in MATLAB R2019a and later, the**Run MATLAB Tests**and**Run MATLAB Command**tasks use the`-batch` option to start MATLAB noninteractively. Preferences do not persist across different MATLAB sessions launched with the`-batch` option. To run code that requires the same preferences, use a single task.
## See Also## Contact UsIf you have any questions or suggestions, please contact MathWorks® at continuous-integration@mathworks.com. |