Programmatically created project is lost when restarting TC server

I use the following code to create a new project and add two build configurations to it in my plug-in:

SProject newProject = myProjectManager.createProject("test");
SBuildType newBuildType1 = newProject.createBuildType("test1");
SBuildType newBuildType2 = newProject.createBuildType("test2");

After running this code, the project and build configurations are all created successfully because I can see them in the web UI.

Also, there are messages in the file teamcity-server.log reporting that the project and build cfgs are created.

However, after I restart TC server, this project including the two build cfgs are all lost as if they were never created.

I know TC projects are saved at %TeamCity_Data_Directory%\config. I also can see a folder named "test" under the directory.

After comparing with the proper project folders, it seems like that the "test" folder lacks two xml files.

I'm very confused.

What is the correct way to cteate a new project programmatically?

I am waiting for answers. Any suggestions will be highly appreciated!

Sun Ding

Comment actions Permalink

Just call the method SProject.persist(). The problem is gone.

My God...

Comment actions Permalink

Sorry for delay with replying. Yes, you need to call .persist() method to flush current settings on disk. TeamCity never does it itself to work effectively in cases when you need to change many things at once.

Comment actions Permalink

Thank you all the same.


Please sign in to leave a comment.