I am having difficulty to phrase the command
tf.exe branch olditem newitem [/version:versionspec]
Especially, I don't know what to put for "versionspec"
I tried this from Powershell:
.\Tf.exe branch $/ProjectA/DEV $/ProjectB/DEV1 /workspace
but I got the below error:
Unrecognized command option 'workspace'.
Can anybody help me set the full command with an example?
If you want to create branch for latest version of your source code you may use branch command without versionspec: https://learn.microsoft.com/en-us/vsts/tfvc/branch-command
If no version is provided, Team Foundation uses the following logic to decide which version of the item to copy to the new branch:
•If a Team Foundation version control server path is specified, then Team Foundation branches the item at the latest Team Foundation version control server version. For example, tf branch $/projects/help.cs uses the server version.
•If a local path is specified for the source, Team Foundation uses the local, workspace version to create the new branch. For example, tf branch C:\314.cs uses the local workspace version.
The branch command copies an item or set of items, including metadata and version control history, from one location to another in the Team Foundation version control server and in the local workspace.
As for what to put for "versionspec", please refer below tutorials:
Versionspecs
A versionspec specifies the version of an item that you want to work
with. You can specify versions in a command either by including the
versionspec as part of the version option (for example,
/version:C1256) or by appending the versionspec to a file name with a
semicolon (for example, filename;Lmylabel).
Source Link
If you want to specify the workspace, you are lacking a W in front of the workspace name. For example: Workspace (Wworkspacename)
A sample full command in cmd with using tf.exe branch command for your reference(my worksace name is PATRICK-W10 in this case):
tf branch $/ScrumProject/TestCaseProject $/ScrumProject/Test /v:WPATRICK-W10
Related
I am trying to run a Jenkins job that uses TFVC plugin. We earlier had a problem with length of the TFS workspace names (exception for length > 75 chars). In order to address this we made a change in the TFVC configuration.
Default workspace name in TFVC: Hudson-${JOB_NAME}-${NODE_NAME}
After change: Hudson-${JOB_NAME}
Post this change the job had one successful run. We are unable to run this repeatedly as the TFS workspace created during the successful run was not deleted. and is throwing the following exception:
FATAL: hudson.remoting.ProxyException: com.microsoft.tfs.core.exceptions.TECoreException: The workspace scanAPI;tfsjenkins already exists on computer ip-XX-XX-XX-XX.
I have tried deleting the Jenkins workspace in pre/post build steps. This has no impact on the TFS workspace.
Additional information: The jobs are being run on a linux node and hence I am unable to run windows commands
You can use Post Build script that use tf.exe to delete the TFVC workpsace, with the delete command.
Create a global environment variable to be able to access the TF.exe easier. for example:
Note: the path to tf.exe it depend to which Visual Studio is installed in the Jenkins machine.
Add a Windows batch command from the scripts menu with the following command:
%TFS% workspace /delete /noprompt /collection:”https://tfs.codeplex.com:443/tfs/TFS27″ “Hudson-%JOB_NAME%;snd\7astlivec_cp”
Replace the URL with your TFS Server URL and change snd\7astlivec_cp with your TFS user. The command is going to delete the newly created TFS workspace.
Another option is to add tf.exe. location to the machine PATH variable and use it directly: tf workspace /delete .......
Update
For Linux, you should be able to use this through team explorer everywhere. It also include a tf command line.
Take a look at Setting up a workspace using Team Explorer Everywhere on Linux
Should be similar on Linux.
Instead of creating the default workspace by specifying workspace name in UI setting, you could also use a Windows batch command to handle this process.
If you want to delete workspace, just add a new post build step, a cleanup command could be added to delete the previously created TFS workspace.
%TFS% workspace /delete /noprompt /collection:"{your-tfs-team-project-collection-url}" "Hudson-%JOB_NAME%;{your-domain-user-name}"
More details your could kindly refer this step-by-step tutorial Jenkins Get Source Code By Specific TFS Changeset
My TFS repo has the following structure:
Project
- Dev
- 1.0.0_Branch1
- 1.1.0_Branch2
- N.0.0_BranchN
The branches are actual branches in TFS.
I have an automated CI build set up for this project on a TFS server. The issue I am having is that I need the build name in TFS to use the name of the branch.
I have tried a number of the build definition variables listed here , for examle $(SourceBranchName) and and $(Build.SourceBranchName) but all of these are instead using the name of the Project (Project in this example).
I would like the build to be named along the lines of 1.0.0_Branch1.1 with the last number being the revision.
The reason I would like to do this is so that when I generate Nuget packages at the end of the build, they can be versioned using the version of the branch that is being built. Currently they are being versioned using the date which means that the highest version is only ever the most recently built, which may not be the case in practice. I don't want to have to manually set the versions each time.
All assemblies that are being built are correctly versioned to match the branch that they are within.
Is there a way to achieve this?
For build definitions, $(SourceBranchName) can be used in the build number format:
example build:
The environment variable is BUILD_SOURCEBRANCHNAME so it will be available as $(BUILD_SOURCEBRANCHNAME) in msbuild.
The list of available variables is found at: https://www.visualstudio.com/en-us/docs/build/define/variables#predefined-variables
This could be caused by the "Mappings" setting you configured under "Repository" tab in your build definition. When you build with TFVC repository, the BUILD_SOURCEBRANCHNAME variable is filled with the last path segment in the root server path of the workspace. So I'm wondering that the mapped server path in your build definition is "$/Project" rather than "$/Project/Dev/1.0.0_Branch1".
TFVC repo branch: The last path segment in the root server path for
the workspace. For example in $/teamproject/main this value is main.
Refer to this link for details: Predefined Variables.
I just started to work with Xcode and trying to add a Subversion repository on remote windows server. When I enter the location path of Subversion repository, it shows following error message:
Error Message :
“Host is not reachable.”
Please can anyone help? Thanks.
Setting up svn source control is always a pain even without Xcode, and Apple couldn't help on it with its integration to Xcode. It changed from version to version and the latest is similar since version 5, so the same is in Xcode 6.
The only problem with this solution that we always have to combine command line and Xcode GUI steps, but this is the only working solution so we will follow this, but using Xcode when it's possible.
As I made it several times but always run into various problems I decided to make a detailed and clear up to date description.
The server side
Even you could install the svn server on your machine it's not a safe solution even you work alone. You could lost your years of work with a faulted hard disk or any accident. So make it on a separate computer.
You need an svn server installation on it and a login. You could check it, just ssh into your server and use the command in terminal
which svn
If you get a version number you have svn possibly with a living repository directory on that server and you can reach it. The exact location is depending on your installation but in our case the main repository directory is: https://myserver.me.com/Library/Subversion/Repository/
You will create your new repository under this directory like
https://myserver.me.com/Library/Subversion/Repository/MyNewApp
1. Create a NEW repository
Login to your server (in our case myserver.me.com) then open the Terminal utility and use the svnadmin create command to create a Subversion repository.
For example, if you want a repository named MyNewApp in the existing location /Library/Subversion/Repository/, you would enter the command:
svnadmin create /Library/Subversion/Repository/MyNewApp
This will create the main structure of the repository. We log out from server to avoid any problem and don't use it directly from now, just from the client side.
The client side
2. Create the folder structure
Note: Creating a hierarchy for your repository is optional. It's not needed in order to get svn to work properly, but if you're
planning on keeping multiple projects under source control, then it's
a good idea to get organized before you start importing those
projects.
We will prepare the folder structure on the client then we will transfer it to server with an svn command named "import".
1.First create a new temporary folder anywhere on your client - for example on your Desktop -with the project/repository name in Finder in our case MyNewApp:
MyNewApp
Then make 3 other folders in it with the exact name:
trunk
branches
tags
2.Import the folder structure to the svn server
Login to you client with Terminal utility and using "cd" command go into the project folder:
cd MyNewApp
Tip: The easiest way to get the full path to a folder into Terminal
without risking typing errors is to first type the cd command and
enter a space, and then drag the folder from the Finder and drop it at
the end of the Terminal command line.
3.Then use the svn import command from Terminal:
svn import . https://myserver.me.com/Library/Subversion/Repository/MyNewApp -m "Initial import of directories for MyNewApp project."
or
svn import . svn+sshtunnel://yourLoginName#194.149.155.124/Library/Subversion/Repository/MyNewApp -m "Initial import of directories for MyNewApp project."
The second is the most secure usage with ssh keys where 194.149.155.124 is the server's IP address. svn+sshtunnel:// means it use svn and sshtunnel but it could be any other depending on the login mechanism like https:// or svn:// The "." after "import" command is important it means the same folder where you are.
If the import was successful, you should see something like this:
Adding trunk
Adding branches
Adding tags
Committed revision 1.
Note: This means this is the first committed version you loaded to the server to MyNewApp repository and it's under revision control by
svn with a message just referencing what you did, and you could use
what you like. Now that you have imported the directory structure for
your project into the repository, you can now delete the MyNewApp1
directory on your computer that you just created. Doing this will help
to prevent confusion later, when you import the real project.
3.Import the Xcode project into svn
Using terminal navigate to you Xcode project and make sure again that you are in the project folder
cd MyNewApp
then use the following svn command again:
svn import . https://myserver.me.com/Library/Subversion/Repository/MyNewApp/trunk/MyNewApp1 -m "Initial import of MyNewApp1 project."
or with an exact location on your computer /Users/myUserName/Apps_Developing/myNewApp
svn import -m "New Import" /Users/myUserName/Apps_Developing/myNewApp https://myserver.me.com/Library/Subversion/Repository/MyNewApp/trunk/MyNewApp1
If the import was successful, you should see the long list of added files...
Note: This means that you import the MyNewApp1 (you could use any
name) project to the trunk under svn. The trunk extension is important
because of naming convention used by Xcode too. Again you can include
any comment you want in the quotation marks, but be sure your comment
will be meaningful to anyone using the repository.
4.Add repository in Xcode
Now launch Xcode and go to Preferences --> Accounts and add new repository with the "+" on the left lower corner
+ Add Repository...
Enter the repository address
https://myserver.me.com/Library/Subversion/Repository/MyNewApp
Note: Don't use the trunk etc. you need the root of the repository here!
5.Checkout the project to create a working copy
In Xcode go to Source Control --> Check Out...
Enter the repository address of the trunk (or branches or tags if you used them earlier)
https://myserver.me.com/Library/Subversion/Repository/MyNewApp/trunk
then give the name of the working copy folder and its location
Note: trunk is important!!! Just type it after the root, if you miss it there will be trunk etc. folders in your folder! Directory name is
as you like for example MyNewAppWorking...then choose location on
your computer like Apps_Developing in our case.
According to this post from January, source indexing was "not supported in TFS Builds running against Git source control". Have any of the updates made this possible yet?
[disclosure - I work on the new build system]
git source indexing is available in the new 2015 build (note this is a completely new modern build system). It's in RC now and shipping soon.
More information available here:
http://aka.ms/vsopreview
specifically: https://msdn.microsoft.com/Library/vs/alm/Build/vs/define-build
Note that if you create a VS definition from the template in the new build system, git source indexing step is there by default.
It will embed a command line for 'tf git view' in the pdb. That command line is available in VS 2015 tf command line.
The task script is open sourced here: https://github.com/Microsoft/vso-agent-tasks/blob/master/Tasks/PublishSymbols/PublishSymbols.ps1
If anyone else comes here looking for a way to index source in a VSTS backed git repo, I modified a powershell script made for github to work with VSTS. The github link to the script in the accepted answer is dead and and pipelines didn't fit my use case. If you just want a script that runs independently of ADO, this might help.
https://github.com/ruckonator/Git-Source-Indexer/blob/master/git-sourceindexer.ps1
This question is related to the last change set id available in TFS, my query is, our tfs collection has multiple branches. I create a work space for each branch and build them.
Now my question is: I wanted to know the last local changeset id of the workspace with which I build the solution.
For example, I build MAIN branch 2 days back, now I wanted to know the last local change set id that is available locally. I used History command but some how it is giving the server changeset not the local changeset id.
Here are my arguments
tf history $/MAIN /collection:tfscollection /format:Detailed /sort:Descending /stopafter:1" ;
In this case, you want to look at the history of your workspace version. TFS tracks (server-side) the versions of files you have locally and defines your workspace version to be the version of the files that you have locally. Contrast that with the latest version which is the current version on the server.
You can use a version spec to indicate what version you want to query, T for the latest version and W for your workspace version.
Another problem, however, is that your current query will only look at the history for the folder you're specifying - that is, when it was added or branched. You will need to perform a recursive query to example all changesets that affect (are beneath) the specified folder.
Thus, your query to get the latest version on the server becomes:
tf history $/MAIN /collection:tfscollection /version:T /recursive /stopafter:1 /format:detailed /noprompt
And to get your workspace version:
tf history $/MAIN /collection:tfscollection /version:W /recursive /stopafter:1 /format:detailed /noprompt