I have TeamCity setup on my server. I have it successfully downloading my source code, and building via Visual Studio. The logs say that the build is successful. However, at this time, the result of the build is in a directory like:
C:\TeamCity\buildAgent\work\688d47a33b8989b6\site
How do I take the contents of the url above and cop them to a directory on the same machine? For instance, I would like to take the contents of the directory listed above and put them in:
C:\WebSites\MySite
How can I do this copy-and-paste within TeamCity so that I have a true continuous integration cycle?
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 3 last lines there are because ROBOCOPY returns non-zero "ERRORLEVEL" values even for a successful copy. You want TeamCity to report the build as broken if ROBOCOPY indeed reports failure, but you want to ignore errorlevel values that indicate success, hence those 3 extra lines.
Also note the "." as the first parameter, the steps in TeamCity start with the working directory set to the working directory of the build, so it should match your build directory.
If you want to avoid overwriting production/testing web.config files with development web.config files, add this to the ROBOCOPY line:
/XF web.config
This will ignore web.config when copying.
Here is a visual of the accepted answer, using TeamCity 9.1.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With