Copy files after build with TeamCity
I have TeamCity on my server. I download my source code successfully and build through Visual Studio. The logs say the build succeeded. However, at this time, the build result is in the directory, for example:
C:\TeamCity\buildAgent\work\688d47a33b8989b6\site
How can I take the url contents above and copy them to a directory on the same computer? For example, I would like to take the contents of the directory above and put them in:
C:\WebSites\MySite
How can I do this for copy and paste in TeamCity so that I have a real continuous integration loop?
thank
source to share
Just create a step that uses ROBOCOPY or similar, use the command line step type and just do something like this:
ROBOCOPY . C:\WebSites\MySite *.* /E /MIR /NP
IF %%ERRORLEVEL%% LEQ 3 set errorlevel=0
IF %%ERRORLEVEL%% NEQ 0 EXIT /b %%ERRORLEVEL%%
EXIT 0
The last three lines are related to the fact that ROBOCOPY returns nonzero "ERRORLEVEL" values even for a successful copy. You want TeamCity to report the assembly as broken if ROBOCOPY does report an error, but you want to ignore the error level values indicating success, and therefore 3 extra lines.
Also notice the "." as the first parameter, the steps in TeamCity start with the working directory set to the build working directory, so it must match your build directory.
If you want to avoid overwriting production / test files of web.config files with development web.config files, add this to the ROBOCOPY line:
/XF web.config
The web.config will be ignored when copying.
source to share
Why would you want to do that. What happens to existing content when the next build occurs? If you are looking for a way to save files generated from an assembly, you should use Teamcity Build Artifacts . This way you can keep what was created as in a specific assembly. All you have to do to do this is update the Artefacts path in the general settings as shown below:
source to share