Get specific versions of TFS code in a different directory - tfs

Currently we have a build process as follows:
I do a build into our dev staging environment.
I label this in TFS.
I use SVN bridge to check out that changeset that was labelled.*
If testing for dev staging passes, I use the working copy I checked out to do another build into the next environment.
I don't want to have to use SVN Bridge to have a copy of my code somewhere else for code at a specific version, but I have not found a way to do this natively in TFS (2010).
Is there a way of doing this (point 3 and 4) using TFS, instead of SVN Bridge?

I may be completely misunderstanding what you're trying to do, but it sounds like you need to create a separate workspace, and get the code that was labeled in step 2 into the new workspace.

Related

Can a TFS2015 script only Deploy (and not Build)?

I am new to the world of scripting with TFS2015. I created a script that builds all of the projects within my solution (it is a rather large solution) and puts it out in a shared folder (where each project has its own subfolder).
I would like to create a separate script for each project that simply copies the bin folder from the shared and pastes it out on my Test environment. I rarely need to deploy everything, so the idea is one build...multiple deploys.
However, when I run my deploy script using the Copy Files step it is doing another build. Although it copies the files that I expect, it is after a full build that creates the folder structure for the build.
Am I able to make the Copy Files step NOT do a Build?
Here is the steps that my script is curently doing:
As you can see, there is only one step (Copy Files) but it still does the Get sources and copies everything into a new folder on the build box like so (where the number keeps incrementing up with each run of the script):
I just want to copy the files from the Source to the Target and not do a build or Get Sources.
It looks like you're still on TFS 2015 RTM or Update 1. Which is already pretty old technology if you compare it to the lifetime of the new build system which was introduced with this version.
TFS 2015 update 2 has introduced a similar system to the Build pipelines to orchestrate Releases. This doesn't require you to map any workspaces or git repositories and can act on the artefacts of your builds or simply on the contents of file shares.
It makes sense that a Build has to build something and in order to build something, it has to get the things to build. If you're actually not building something, then you're probably deploying or releasing or packaging something else. Hence the distinction between Build and Release pipelines.
TFS 2017+ has an option to disable the syncing of sources. Primarily to allow people to get the sources themselves in creative ways (e.g. a custom powershell script that invokes git.exe).
My primary advice would be to upgrade to TFS 2018 update 3 or at least TFS 2017 update 3.1, worst case TFS 2015 update 4.1. The fact that versions older than update 2015.4.1 have a known XSS scripting security bug may be reason enough to convince your organisation to perform this update.
Barring that option you're left with one solution:
Link your build definition either to a git repository with only a single commit (If I remember correctly the 2015 agent still crashes when syncing an empty Git repo) or link it to a TFVC repository and set the workspace settings to cloak everything. This essentially causes the build to sync an empty folder, which it can cache, before calling your powershell script.

TFS 2017 Build definition: how to get sources from another TFS

I have two different TFS instances. Both use TFVC as a source control.
I want to set up a build definition on TFS1, so that it gets sources from TFS2. Is it possible to do it?
There is no option "Remote TFVC", only "Remove Git".
Thank you.
As far as I can tell, it isn't supported in either TFS On-Prem, or VSTS. Depending on your needs, circumstances and limitations, you might consider one of the following options (all are more or less trade-offs):
Migrate sources from TFS2 to TFS1 (the one to run builds)
This seems to be the correct thing to do, but it is a time-consuming and error-prone process
Fake the Get Sources action and do the real get/checkout in the first build step
You can configure the Get Sources step to address any Git repo in the same team project, and turn the Don't sync sources flag ON. Then, in the first real build step, run command-line Get (something like this)
You may use custom build step (cmd or bat file) and download files from remote server. Examples:
Copy files from tfs versioncontrol to directory with PowerShell
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/9559f7a5-405a-456c-a66b-8123d52ed23a/how-to-copy-a-folder-from-tfs-source-control-to-shared-location-with-powershell-script?forum=tfsgeneral
You could just add the extension to get them from an external vsts/tfs.
Go to the marketplace and search for them (see image).
You will have to configure a endpoint to your external vsts/tfs, but it is quit easy to do.
You can install this extension: TFS artifacts for Release Management.
Then add a Download Artifacts-External TFVC task from Utility.

TFS (CI) - Only one branch has just been check-in/pushed to be built

I'm trying to deploy a Continuous Integration server where I work.
We used TFVC with the branch to release strategy, but we are having difficulty with something that should be trivial.
We only need the build on the branch that was checked in.
Is it possible to do this without having to change the build definition every time a new branch is created?
I do not want to map the entire folder structure of the repository. Imagine having 10 branches and every check-in, build all? Does not make sense!
Anyone have any idea how to do it?
The CI build for TFVC can’t map and just build target branch like build for Git.
There are some workarounds:
Clone a build definition and change source mapping, Path filters of triggers for each branch.
Add a PowerShell step/task to get recent check-in change by calling get changesets Rest API, then store the related solution/project files in a variable by using Logging Commands, then build these solutions/projects

TFS lab build - get staging drop folder

We have a customized lab build. We are using the latest build from a specific build definition.
Our testing agent is on another network with shared drop folder, and we need to copy files to this folder before running the tests.
The latest folder is defined in the staging section of the build definition (under Build Defaults). How can I get it in the xaml?
I tried "BuildDetail.DropLocation", but gets nothing (prints an empty string).
We are using VS2012, the server is TFS 2013.
Thanks,
Annat.
Update: Found the solution in my case. Just had to use "BuildDetail.DropLocationRoot".
I wrote some note on the subject on a post, which can give you some ideas on managing drop folders and avoiding copies.
Answering your question, the simplest way is to use the TF_BUILD_DROPLOCATION environment variable in a script.

Creating an on Demand Deployment from TFS using a label

I have build scripts that builds, test, version and packages my projects as artifacts to a staging area for each of our environments ready for a versioned release to a given environment (and labels the changeset).
I want to stop doing this automatically and only deploy on demand.
My problem is I am using TFS and the friction is just immense.
I basically want to have an easy way to
Get a specific version from source control
build it for a specific enviroment -DONE
deploy it. -DONE
The last 2 steps are trival. The "getting by label" it not that much fun with TFS.
Any ideas/pointers other than use stop using TFS?
just ask on twitter next time :-)
Seriously though, have a look at TFS Deployer on codeplex. The way it works is that you do a normal build with versioning of the output like you normally would, but you pull out all the deployment stuff from it.
Next, setup TFS Deployer - it listens for changes in the Build Quality and the fires off a powershell script that you write that does all the deployment work. For example, when you change the quality of a build to something like "deploy to UAT" it can fire off a powershell script that then does whatever you need it to. To do a deploy you just go to build explorer, set the quality to whatever you want and let powershell do the rest - you'll get an email of the results as well so you know if it works or fails.
Go have a look at it and if you get stuck just ping me and I'll help you out.

Resources