Skip to content

The Jenkins plugin for MATLAB® enables you to easily run your MATLAB tests and generate test artifacts in formats such as JUnit, TAP, and Cobertura code coverage reports.

Notifications You must be signed in to change notification settings

hkhan17/jenkins-matlab-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Jenkins MATLAB Plugin

Description

The Jenkins plugin for MATLAB® enables you to easily run your MATLAB tests and generate test artifacts in formats such as JUnit, TAP, and Cobertura code coverage reports.

Build Step Configuration

To invoke this plugin, select "Run MATLAB Tests" from the Add build step list.

new_add_build_step

new_default_plugin_page

Use the plugin as part of the Jenkins build step to run MATLAB tests in two distinct modes:

  • Automatic
  • Custom

Enter the value returned by “matlabroot” in the field named “MATLAB root”.

new_enter_matlabroot

Configuring “Automatic” Option

This option finds tests written using the MATLAB unit testing framework and/or Simulink Test and runs them. If the code is organized using projects, it will locate all test files in the project that have been classified as "Test". If the code does not leverage projects or uses a MATLAB version prior to R2019a, the plugin will discover all tests in the current Jenkins workspace including subfolders.

If you are using a source code management (SCM) system such as Git, then the job must include an appropriate SCM configuration to check out the code before running the MATLAB plugin. If you do not use any SCM systems to manage your code, then an additional build step is required to ensure the code is available in the workspace before running the MATLAB plugin.

The automatic test running feature enables you to generate different types of test artifacts. They could be used with other Jenkins plugins as part of a post-build action to publish the test results. To configure the Jenkins build for running MATLAB tests automatically, follow these steps.

  1. Select the Test mode as Automatic to run tests (Automatic is the default mode).

new_select_automatic_option

  1. Select the desired test artifacts. You can also choose not to generate any test artifacts.

new_select_all_test_artifacts

The selected test artifact(s) will be stored in the “matlabTestArtifacts” folder of the Jenkins workspace.

Workspace01

Test_artifacts

If the user does not select any test artifact generation checkboxes, this folder will not be created under the workspace and no test artifacts will be generated. However, test execution still occurs and test failures will fail the build.

The Automatic test run mode generates a MATLAB script file named “runMatlabTests.m” in the Jenkins workspace. The plugin uses this file to run tests and generate test artifacts. You may review the MATLAB script to understand the test workflow.

Workspace01

Configuring “Custom” Option

This option enables you to develop your custom MATLAB commands for running tests.

  1. From the "Test mode" dropdown list, select “Custom” option.

new_select_custom

  1. In "MATLAB command” text box, enter your MATLAB command. Separate multiple commands by commas or semicolons.

new_custom_runtest_command

Note: If you require several MATLAB commands to execute your test session, consider writing a MATLAB script or function as part of your repository and executing the script or function instead. Test artifacts are not autogenerated if you choose to run tests using your custom MATLAB commands. You can generate these and other artifacts by configuring a test runner in the script or function invoked by the command. The build will fail if the execution of any MATLAB command causes an error.

new_custom_script_example

Configuring "Multi-configuration"(matrix) project.

The Jenkins plugin for MATLAB can be used inside of "Multi-configuration" (matrix) projects. Matrix projects allow jobs to be repeated with different configurations, such as testing on multiple platforms or testing against multiple MATLAB versions.

Matrix build for "Automatic" option.

  1. Create a "Multi-configuration" project.

image

  1. Add User-defined axis for different MATLAB versions as shown below.

image

  1. Replace the User-defined axis variable in MATLAB root appropriately.

image

  1. Save and run the build.

Matrix build for "Custom" option.

  1. Create a "Multi-configuration" project.

image

  1. Add User-defined axis for different MATLAB versions as shown below.

image

  1. Add another User-defined axis for custom commands as shown below.

image

  1. Replace the User-defined axis variable in MATLAB root appropriately.

image

  1. Select "Custom" option from "Test mode" drop-down and replace User-defined axis variable for custom command appropriately.

image

  1. Save and run the build.

Note: Axis variables can be replaced in either "$VAR" or "${VAR}" formats. Do not use complete MATLAB root path as axis values. Multi-configuration project creates separate workspace folder for each User-defined axis values with same name, and file separators in complete path will cause Jenkins build to fail as folder creation fails.

Contact Us

If you have any questions or suggestions, please feel free to contact MathWorks.

support@mathworks.com

License

MIT © 2019 The MathWorks, Inc.

Build Results

Overall Linux Windows Mac
Build Status Build Status Build Status Build Status

About

The Jenkins plugin for MATLAB® enables you to easily run your MATLAB tests and generate test artifacts in formats such as JUnit, TAP, and Cobertura code coverage reports.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 89.3%
  • MATLAB 6.4%
  • HTML 3.0%
  • Other 1.3%