Matlab and Jenkins CI

10 次查看(过去 30 天)
In brief, I'm hoping to take over a matlab project of moderate complexity. The strategy is to unit test. My experience is that continuous integration is a very effective tool for automating these kinds of activities. I've tried to follow this post;
But I'm stuck. Matlab appears to not communicate with any other process which spawns it - I've tried from the command window and I have the same problem. In the blog post, Andrew Campbell is able to print 'hello world' to the jenkins console via the matlab process.
I cannot achieve this, or actually even get the matlab splash info to be displayed in either jenkins or just a pure cmd window. Even using the -nodesktop modifier, it simply spawns it's own custom console rather than using the existing one.
I have matlab R2015a and windows 8.1.
Has anyone successfully setup Jenkins on windows with Matlab? I'm hoping someone can confirm it should be possible possible before I spend more time on it? It's the sort of thing I had hoped would be easy :-(.
  2 个评论
Simon Parten
Simon Parten 2015-9-3
More info;
I downloaded the example project from this post.
I can run the tests from the command line using this in the cmd shell, which opens a matlab console.
matlab -nosplash -nodesktop -wait -r "loadTestModule;runUnitTestsAutomatic" -sd "C:/temp/aahhhh/example_project"
But trying to run the same in jenkins fails... basically withou any further help.
Simon Parten
Simon Parten 2015-9-3
So, after more poking around, I found the matlab -logfile option. Apparently starting Matlab from the command line meant that matlab didn't find it's license file, and failed silently.
Now, I've added a -c option, which points matlab to a valid license file...
Current behaviour is that it appears to kick off a 'matlab start' process, and a matlab process, and then hangs ...
- The logfile is blank - After 5 minutes there is no activity

请先登录,再进行评论。

采纳的回答

Simon Parten
Simon Parten 2015-9-3
编辑:Simon Parten 2015-9-3
So, it appears to depend on how you install Jenkins. To someone reading this who wants matlab - Jenkins CI on windows. Some hints;
Do NOT install jenkins as a windows installer from the jenkins homepage It sets itself up as a windows service with some sort of service account. I didn't have permission to mess with that and set it to be myself, so I and ended up in a world of pain.
For success, suggest a different strategy of setting up your own webserver and hosting jenkins inside. Sounds harder than it is;
  1. download and extract tomcat from a zip file
  2. download jenkins war file and place in webapp directory of downloaded tomcat
  3. modify tomcat-users.xml to include yourself as a tomcat user with manager-gui role
  4. setup the JAVA_HOME enivronment variable to reference your java installation
  5. move to tomcat bin dir and type 'start' ... for whatever reason, this appears to be the key part as it means jenkins ends up running as you, not a service account.
Note that you now have a potentially unsecured webserver available to whoever can see your computer... this may not be wise.
However you can now follow the instructions Andrew lays out in the two CI blog posts and actually automate running some tests - woot.
  2 个评论
Erwin Hoogerwerf
Erwin Hoogerwerf 2019-9-16
An alternative method to achieve the same as the solution by Simon above, which will also work if you have already installed Jenkins as a service. We can actually change the user account that is used to run the Jenkins service.
  1. In windows services, search for the jenkins service -> properties -> log on (tab) and tell windows to use a specific account. Here, use an account that can start Matlab. This can be the current user, but be aware this can be abused as mentioned above.
  2. Go to the jenkins home folder and open jenkins.xml in any text editor. Change the name field to the specific account used in the step above.
  3. Restart the jenkins service
Brandon Smith
Brandon Smith 2020-6-12
I second Erwin's comment. This is substantially easier to do. Just open the Windows 'Serviced' App and look for the already installed Jenkins service.

请先登录,再进行评论。

更多回答(1 个)

Houman Rastegarfar
Houman Rastegarfar 2023-7-14
You can install the MATLAB plugin for Jenkins to easily run a MATLAB build, as well as MATLAB tests, scripts, functions, and statements. For more information, see Continuous Integration with MATLAB on Jenkins.

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by