In TeamCity 8.1 I've just pulled down my source code and the first thing I want to do is delete a bunch of subfolders from what I've just retrieved.
I can't use exclusions in the 'Checkout Rules' so I guess I need a separate step to run immediately after retrieving source code.
I guess I need a CommandLine Step? If so I can't seem to find much information about using this to delete a number of sub folders?
Anyone with experience in this area?
You can do it in two ways
use a command line to delete the folders using windows/unix commands. Teamcity publishes a property called teamcity.build.checkoutDir using which you can go the directory and run the necessary delete commands(based on the OS where you are checking out).
A better way of doing this would be to add a target in your build.xml and call the target as the first step of your build
In our team city setup we wanted to delete all existing files in working directory.
We have first build step which cleans up working directory contents using custom command line script.
del /s /q .
for /d %%%y in (.\*) do #rd /s /q "%%%y"
Note: We don't have VCS attached in this build configuration. If you have VCS attached then this solution won't work because TC will first download/copy contents from VCS then this build step will delete all the contents downloaded from VCS.
Related
In TFS the Build number format usually looks something like this:
$(BuildDefinitionName)_$(Date:yyyyMMdd)$(Rev:.r)
However, I only want to retain 1 build and I would like it to build to the same folder each time. So I tried changing it to this:
$(BuildDefinitionName)
But the problem is that this only works one time, then gives an error that the build number already exists after that. I would like to build to the same folder so that I can write a script to zip the latest build, move it to another place, and then unzip it and it would just be much easier if I didn't have to deal with writing code to figure out what the most recent folder name is.
Is there a way to accomplish building to a folder name that doesn't change?
This is by designed, every completed build should has a unique build number/name. Otherwise you will get the error above.
$(Rev:.r)
Use $(Rev:.rr) to ensure that every completed build has a unique
name. When a build is completed, if nothing else in the build number
has changed, the Rev integer value is incremented by one.
As a workaround: For vNext build, you could use a copy Files task to copy the build output to the same folder during the build pipeline. To make sure you will always only get the latest build, you could add a powershell script before the copy task to clean/delete files in that special target folder.
For XAML build you need to customize the build template and add the default CopyDirectory activity in build template to copy the build result to the specified drop location. The detailed steps please refer to this blog. Also add a pre-build script to do the clean operation.
Could someone help me: How to get latest version of multiple files in TFS?
I'm starting to try automating the publishing of a project that is often changing, start with this problem.
So let's say that I have a list of 10 changed files in TFS that is not in the same changeset, and I need some tool/add-in/script that can get latest version of all those 10 files in one click/enter.
Anyway to do that, or any suggestion for me to start searching? Thanks for any help!
You can call the tf.exe command like this:
tf get file1.cs
tf get file2.cs
...
And then do that for every file. If they are all in the same folder you can just specify the folder and all files will be refreshed. You can also specify their common ancestor and add the /recursive option:
tf get ancestorFolder /recursive
Here is the full reference for the tfs get command.
Assuming that you know which files you need, the below script can help.
tf get "tfs path to file/folder" /force /recurse
use /force when you need to overwrite existing file. use /recurse when you want to get all files within a folder.
you can run this inside dos for loop command. Something like:
FOR /F ["options"] %%variable IN (<file name containing list of files>) DO tf get "%%variable" /force /recurse
You would need to study ["options"] as it's difficult over here to explain everything.
Alternatively you can use same logic inside powershell but there you would need to load tfs assemblies and run the required commands but will give you more flexibility and control with what you want to do.
Get Latest Version of Folder from TFS, using Powershell
How to get latest version of specific project in TFS using Powershell.
I am facing an issue when trying to generate build. I have post deploy batch command where I am copying files and folder using xcopy.
This doesn't seem to work.
Is there any solution or work around for this.
On TFS and VSTS you should use the Copy Files task provided.
https://www.visualstudio.com/en-us/docs/build/steps/utility/copy-files
Just drop the task onto the execution stuck and configure it as per the documentation.
You will still not be able to access disc location outside of the agent permission scope.
I have checked the option in TeamCity which says "Clean all files in the checkout directory before the build". But it doesnt seem to delete the folder on the server before it builds and deploys the code. There are always stray files which are no longer needed. Is there any better process / Can we achieve by adding extra command line parameters to Build Step to achieve this?
Thanks.
Try setting specific folder as the Build Checkout Directory (instead of using default one). You can set this in your VCS Settings page.
You would also need to select the option the to clean directories before checkout for every run. Otherwise you wil still be left with the issue of stray files
I need to make some changes to Qt 4.7.1, so I need to add it to my subversion server to track my changes. However, once it's added, the configure script fails. I'm guessing it's choking on the .svn files.
I'm using Windows. Is there any way to add Qt to subversion, delete all the .svn folders, configure and build it, recreate the .svn folders, and then submit my changes?
Or is there any other work around? The error I get is 'Couldn't update default mkspec'
Here is what I would have done:
Install Qt in some folder.
Make sure that auto-props and global-ignores are set up properly.
Rename the whole folder.
Create an empty repository.
Create an empty folder having the same name as the original one.
Import the empty folder into the repository.
Remove the folder.
Check out the folder.
Copy the contents of the backup to the working copy.
Carefully add everything you want to be source controlled, probably using the -N or --depth options.
Put everything else into appropriate svn:ignore properties.
Commit.
Compare the working copy and the backup.
If there are any differences, wipe both the working directory and the repository, then repeat from the step 2, correcting the mistakes.
It may seem a bit of overkill, but importing such a large project into an SVN repository isn't a trivial task.
The problem is if .svn folders exist in /mkspecs/default and /mkspecs-win32-msvc2008 then configure fails to run with the error 'Couldn't update default mkspec'
If I move the .svn folders, configure, then replace them, I can then build.