Now that we have MATLAB projects self-describing how they can be tested, let me get after what I hinted at last post . In particular, how easy it is to get the project set up and ready to roll with your automated CI build. We have discussed many times on this blog how to get squared away with your MATLAB and Simulink code on Jenkins, but we have never discussed how we are working to make it easier for you. This needs to be rectified!
Turns out, we've been up to some stuff. In particular, one of the "stuffs" we've been up to is providing a Jenkins plugin to reduce the time and effort it takes you to get up and running with your MATLAB and Simulink builds.
This, in combination with the test-aware projects now provided in MATLAB, enables a truly push-button Jenkins experience (also a configuration-as-code experience for those of you preferring that over push-button). Let's see how this is done with our new favorite project, libDirectional.
Last time we projectified it and enabled Test labels to help define the tests in the project. Now the Jenkins plugin just knows what to do. Wanna see it in action? Me too let's go.
First ya gotta get the plugin installed. This is actually pretty easy, you can find it on the Jenkins plugin index.
From there you or your Jenkins administrator can download it and install it directly. However, its actually much easier just to install it directly within Jenkins.
Now that the plugin is installed, let's set up our project and get going. All it takes is
- Point the git details to libDirectional
- If desired, specify where MATLAB is on your build agents. This step isn't needed if your build agents are already configured with MATLAB on the system PATH. The location specified in the plugin will simply add the MATLAB location specified to the PATH, but if invoking "matlab" from the terminal or shell finds the right desired MATLAB on your build machines you can skip this.
- Now we can go ahead and run the MATLAB tests in the project. You even have one click access to produce a variety of test artifacts such as test results, reports, and coverage information. Using these artifacts you can leverage a variety of other plugins and features of the Jenkins environment to get more insight into your build.
All 3 of these steps are shown here:
Super easy, but when we run the build we will see it fails:
If you are familiar with the project, looking at the test results makes it clear that these tests failed because the required mex files were missing. Of course! We need a build step. To do this, we can leverage the other build step provided by the plugin to run an arbitrary MATLAB command. This repository is nicely configured to have a simple way to build all of its mex files, and it's a function called compileAll. Put a call to that function, preceded by a call to open the project, in a build step prior to running the tests and that's all we need to do.
So there we go, that's how we can use the Jenkins plugin to set up MATLAB build quickly and easily. It's so simple that it may be easy to not realize some of the things this is buying you:
- Quick and easy production of MATLAB and Simulink CI artifacts
- Minimal CI configuration
- No need to understand the "best way" to launch MATLAB for a CI build. No longer will you forget the try/catch or try to remember the precise MATLAB startup options needed in 17b for the optimal way to run MATLAB in CI
- Support for testing workflows back to 13b, and even supports matrix builds for testing different versions of MATLAB on different platforms. All you need to specify is the MATLAB command you'd like to use or your test configuration. All else is handled for you by the plugin.
There ya go, the Jenkins plugin always doing its part to help improve your CI workflows with MATLAB and Simulink.
We have also heard from several of you who are not using Jenkins and who are interested in other CI platforms and services. Well rest assured that we are hard at work supporting other platforms as well and have much more to blog about. What CI platforms are you interested in hearing more about?
要发表评论，请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。