Matlab called in batch file

Hello,

So I have a batch file that performs all the tasks I need it to do but when I get to the step that perform some Matlab code generation, I just doesn't do it.

In TeamCity it calls matlab then does 1 of my 2 initialization scripts then exits. I cannot figure out why this is. Also after those initialization steps I need to open a file (because it has custom functionality that only works when it is open) then call a function that performs a task on that model.

This all works fine the way I want in command line. the matlab step is the only thing that doesn't work properly in TeamCity.

Any Ideas?

Thanks
wagner2x

11 comments
Comment actions Permalink

Hello,

Did you try to run the same script via the command line on the same machine as TeamCity agent running and under the same user? Does it run successfully?
Please follow this guideline for troubleshooting.  

0
Comment actions Permalink

yes and i works fine. Which is why I am confused :p

0
Comment actions Permalink

Do you run agent as Windows service? If yes, please try running the TeamCity agent from the command line.
If the build succeeds from the console but fails in command line runner in TeamCity, most probably this is an environment or a tool issue. Please investigate it on your side.

If you could not find the root of the issue then lease attach full build log and teamcity-agent.log.

0
Comment actions Permalink

As you can tell by my profile, I'm a newbie :p so after I start the agent in the command line then what do I do? Do I build it in the Teamcity UI or do I build it in the cmd line?

Also, what exactly is the build agent?

0
Comment actions Permalink

To start the agent manually, run the following script via the command line:

  • for Windows: <installation path>\bin\agent.bat start
  • for Linux and MacOS X: <installation path>\bin\agent.sh start


For more details please see https://confluence.jetbrains.com/display/TCD9/Setting+up+and+Running+Additional+Build+Agents#SettingupandRunningAdditionalBuildAgents-StartingtheBuildAgent.

0
Comment actions Permalink

Yea I got it to start in the command line but don't know where to go from there.

0
Comment actions Permalink

A TeamCity Build Agent is a piece of software which listens for the commands from the TeamCity server and starts the actual build processes.
You can run it as windows service or from command line. The newly installed agent connects to the server for the first time, it appears on the Agents page, Unauthorized agents tab visible to administrators/users with the permissions to authorize it. Agents will not run builds until they are authorized in the TeamCity web UI. The agent running on the same computer as the server is authorized by default.
You can check the available agents on Agents tab in TeamCity UI. If the agent is available, then you can run a build on it.

0
Comment actions Permalink

Does the build agent have capabilities to run more than one matlab command per matlab call? For example


<MyProjDir>>matlab -logfile C:\loglocation\MLoutput.txt -noFigureWindows -nosplash -nojvm -r -wait "try; run('C:\initLocation\Init1.m'); run('C:\initLocation\Init2.m'); cd ModelLocation; open Model.mdl; Call_CustomFn(); catch; end; quit;"

When I run this line in the teamcity build agent it does the init1 script and prints the results to the MLoutput.txt but it does not do the init2 or the Call_CustomFn(). However, when I run my bat file from the command prompt it works like it is supposed to.

0
Comment actions Permalink

TeamCity build agent command line build step should start the script the same way as you run it using command line.
Does TeamCity print any errors/warnings in the build log?

0
Comment actions Permalink

It does not. I get to the matlab command and it waits for a second while it performs the first init script but then exits and continues with the rest of the commands. The only thing printed to the MLoutput log file is what the 1st init script prints and that is it.

0
Comment actions Permalink

Hi Benjamin,

Sorry for delay. How did you configure the command line build step? Do you run Custom script or Executable with parameter? Please try to use Executable with parameter.
Also please try to add logging to the script, it sould help to find the place when/why the build stops.

0

Please sign in to leave a comment.