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 release on the system path to execute your pipeline.
- To use a Microsoft-hosted agent, you must include the Install MATLAB task in your pipeline to install your preferred MATLAB release on the agent.
## ExamplesWhen you author your pipeline in a file named - To install a specific release of MATLAB on a Microsoft-hosted agent, use the Install MATLAB task.
- To run a MATLAB build using the MATLAB build tool, use the Run MATLAB Build task.
- To run MATLAB and Simulink® tests and generate artifacts, use the Run MATLAB Tests task.
- To run MATLAB scripts, functions, and statements, use the Run MATLAB Command task.
## Run a MATLAB BuildUse MATLAB R2022b or later on a self-hosted agent to run a MATLAB build task named
## Generate Test and Coverage ArtifactsUse the latest release of MATLAB on a Microsoft-hosted agent to run the tests in your MATLAB project and generate test results in PDF and JUnit-style XML formats and code coverage results in Cobertura XML format. Use tasks to publish the generated artifacts to Azure Pipelines once the test run is complete. To install the latest release of MATLAB on the agent, specify the
You can access the artifacts in the pipeline summary window: - To download the PDF test report, follow the
**1 published**link. - To view the test results in JUnit-style XML format, open the
**Tests**tab. - To view the code coverage results in Cobertura XML format, open the
**Code Coverage**tab.
## Run Tests in ParallelUse the latest release of MATLAB on a Microsoft-hosted agent to run your MATLAB and Simulink tests in parallel (requires Parallel Computing Toolbox™). To install the latest release of MATLAB, Simulink, Simulink Test™, and Parallel Computing Toolbox on the agent, specify the
## Run MATLAB ScriptUse MATLAB R2023b on a Microsoft-hosted agent to run the commands in a file named
## Specify MATLAB Release on Self-Hosted AgentWhen you use the You can prepend your preferred release of MATLAB to the
## Use MATLAB Batch Licensing TokenOn a Microsoft-hosted agent, you need a MATLAB batch licensing token if your project is private or if your pipeline includes transformation products, such as MATLAB Coder™ and MATLAB Compiler™. Batch licensing tokens are strings that enable MATLAB to start in noninteractive environments. You can request a token by contacting MathWorks® at batch-tokens@mathworks.com. To use a MATLAB batch licensing token: - Set the token as a secret variable. For more information about secret variables, see Set secret variables.
- Map the secret variable into an environment variable named
`MLM_LICENSE_TOKEN` in each of the**Run MATLAB Build**,**Run MATLAB Tests**, and**Run MATLAB Command**tasks of your YAML pipeline.
For example, use the latest release of MATLAB on a Microsoft-hosted agent to run the tests in your private project. To install the latest release of MATLAB on the agent, specify the
## Build Across Multiple PlatformsThe
## TasksYou can access the extension tasks and add them to your pipeline when you edit your pipeline in Azure DevOps. ## Install MATLABUse the Specify the
## LicensingProduct licensing for your pipeline depends on your project visibility as well as the type of products to install: - Public project — If your pipeline does not include transformation products, such as MATLAB Coder and MATLAB Compiler, then the extension automatically licenses any products that you install. If your pipeline includes transformation products, you can request a MATLAB batch licensing token by contacting MathWorks at batch-tokens@mathworks.com.
- Private project — The extension does not automatically license any products for you. You can request a batch licensing token by contacting MathWorks at batch-tokens@mathworks.com.
To use a MATLAB batch licensing token, first set it as a secret variable. Then, map the secret variable into an environment variable named ## Run MATLAB BuildUse the Specify the task in your YAML pipeline as
When you use this task, a file named ## Run MATLAB TestsUse the By default, the task includes any files in your project that have a Specify the
## Run MATLAB CommandUse the Specify the task in your YAML pipeline as
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
## Notes- By default, when you use the
**Run MATLAB Build**,**Run MATLAB Tests**, or**Run MATLAB Command**task, the root of your repository serves as the MATLAB startup folder. To run your MATLAB code using a different folder, specify the`-sd` startup option or include the`cd` command when using the**Run MATLAB Command**task. - 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. |