Skip to content

Instantly share code, notes, and snippets.

@dapperfu
Created March 19, 2017 04:15
Show Gist options
  • Save dapperfu/42e682dc796e5eb0998ce3db3d0808f5 to your computer and use it in GitHub Desktop.
Save dapperfu/42e682dc796e5eb0998ce3db3d0808f5 to your computer and use it in GitHub Desktop.
Jenkins skeletons for running Matlab from Jenkins.
@echo off
REM This batch file is a short example of how to call
REM MATLAB from the command line.
REM Options:
REM -nosplash Don't display the MATLAB Splash screen
REM -wait Don't return to the script until MATLAB is closed.
REM -c explicitly specify the license file.
REM -logfile Log all script output to the logfile.
REM -r Run the specified matlab commands.
"C:\Program Files\MATLAB\R2016b\bin\matlab.exe" -nosplash -wait -c "C:\Program Files\MATLAB\R2016b\licenses\network.lic" -logfile "%~n0.log" -r "cd('%~dp0');run('%~n0')"
%% Start Jenkins Matlab Script.
fprintf('########## Started ##########\n');
try
%% BEGIN YOUR CODE HERE
%% END YOUR CODE
catch me
fprintf('########## Failed ##########\n');
% Print error
fprintf('ERROR: %s (%s)\n\n',me.message, me.identifier)
% Print full stack
for i = numel(me.stack):-1:1
fprintf('[Line %02d]: %s\n',me.stack(i).line,me.stack(i).file)
end
% Exit with non 0 error.
exit(1);
end
fprintf('########## Finished ##########\n');
exit(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment