I am creating a batch build script.
I need a tfs cmd command to print all the change sets included in my get.
i failed to google it so far, appreciate any help.
I found a solution.
You can use the tf history command, you can compare the history of the local workbench vs the server.
Try this command:
tf history xxx.sln /noprompt /v:Cxx~W
Cxx: Get the changset of the time you would do the last get.
W: Specifies the version in your workspace.(Current)
Related
In my TFS release i added a script to create a label when a certain environment succeeds.
This label is apply on a given server item and for a specific Changeset.
The TF.exe command looks like this:
tf.exe label Main-Approved $/MyProject/Main /recursive /version:C124730 /comment:"Approved by Main Release" /collection:http://tfsserver:port/tfs/MyCollection
However when run from the release i get the following error message return by TF.exe:
Error: There is no working folder mapping for D:\Agent-Default_work\r144\a\by.
Running this exact command localy works fine and creates the label.
I don't understand why i would need to create a workspace and some folder mapping in order to apply a label on a Server item (using $/...) for a specific changeset?
Any help would be appreciated.
Thanks!
So i was using a Python script to run the command.
I tried changing it to a powershell script and it works.
My guess is that in python the strings were passed incorrectly someone. I feel like the workspace 'by' was in fact my command wrongly parsed by the intepreter and considered an argument in tf.exe.
We are running Jenkins as our build server and on-prem TFS as our source control. We are using SonarScanner for MSBuild step before the build, and one of the fields which can be populated is "project Version". The value in this field will tag the sonar analysis with the version.
I have tried the following values:
$TFS_CHANGESET
${TFS_CHANGESET}
${ENV,var="TFS_CHANGESET"}
but unfortunately I just get the literal text that is put in, not an evaluation of the environment variable.
Is there a way to get the actual environment variable evaluated and it's value used instead? The sonarqube scanner documentation does not appear to provide information on how to use environment variables, and the various posts I have read, leading to the values I have tried do not appear to work either!
Ref:
https://community.sonarsource.com/t/expand-environment-variables-in-sonarqube-scanner-for-jenkins/4711
How to correctly get TFS changeset number into Project Version field of SonarScanner on Jenkins?
If you are using the default way to download your code from Azure DevOps Server by through the usage of the Source Code Management Tab, it seems we could not configure it to download the source code by a particular changeset number.
To resolve this issue, you could use Windows batch command to get the latest source code:
%TFS% workspaces -format:brief -server:{your-tfs-team-project-collection-url}
%TFS% workspace -new Hudson-%JOB_NAME%-MASTER;{your-domain-user-name} -noprompt -server:{your-tfs-team-project-collection-url}
%TFS% workfold -map $/{tfs-path-to-your-sln} C:\Jenkins\jobs\%JOB_NAME%\workspace\ -workspace:Hudson-%JOB_NAME%-MASTER -server:{your-tfs-team-project-collection-url}
%TFS% get $/{tfs-path-to-your-sln} -force -recursive -noprompt
%TFS% history $/{tfs-path-to-your-sln} -recursive -stopafter:1 -noprompt -format:brief -server:{your-tfs-team-project-collection-url}
Please check the document Jenkins: Get Source Code By Specific TFS Changeset for some more details.
Hope this helps.
I'm trying to use tf branch, but get this error:
no appropriate mapping exists for $/main_folder/folderB/folder1
below is my command:
tf branch $/main_folder/folderA/folder1/file.sql $/main_folder/folderB/folder1
Any ideas why?
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.
According to above error info, you also need to map your $/main_folder/folderB/folder1 path to your local workspace. Then try to perform the command again.
More detail tutorial about how to use this command please refer this official tutorial: Branch Command
A sample full command in cmd with using tf.exe branch command for your reference:
tf branch $/ScrumProject/TestCaseProject $/ScrumProject/Test /w:WPATRICK-W10
I appear to have some problems with my workspace cache. When I type:
tf workfold
In my workspace directory, I get the error:
Unable to determine the workspace
This article seems to imply that it’s a problem with the cache. Being cautious, I tried removing a single workspace:
tf workspaces /remove:WORKSPACENAME /server:servername
This seemed to work (that is, the command succeeds), because if I do it a second time it fails. However, when I issue:
tf workspaces
It still lists this workspace, and I still get the error.
Can anyone give me any guidance of the next step here? I assume what I’m deleting it the cache for the workspace and not the workspace itself, do I need to clear all my workspaces for this to work? If so, why might this make any difference?
Try running below command to refresh the cache:
tf workspaces /s:http://tfs-server:8080
this might be a daft question but are you running the tf workspaces command from a folder that's mapped to the workspace? e.g. your workspace mapping is something like $/MyTeamProject/Source -> c:\source
when you open your command prompt you should cd c:\source before running tf workspaces
You can try this one to delete the workspace:
tf workspace login:[your login credentials] - delete workspacename -collection:[collection URL]
example:
tf workspace login:US\\saket.kumar - delete saketworkspace1 -collection:https://tfs1101.client.com/tfs/CTS
I am using an InvokeProcess activity in TFS 2010 to try and run the corflags application on a built exe.
C:\Builds\4\testing\Sources\BuildAssets\corflags.exe C:\Builds\4\testing\Binaries\Executable.exe /32bit+
However I am getting the following message:
corflags : error CF001 : Could not open file for writing
I am running the TFS Build Agent on my local machine because I am currently in a testing phase, and when I run the exact same command from the command line, the corflags application completes without error.
Any ideas would be greatly appreciated.
I'm not familiar with the specific situation but some general ideas:
Who is the build running as? Does that user have permissions to the output path?
Another consideration is: Has the build completed before it attempts to execute your command?
Try changing the command to be something really simple eg Type "OutputFile" - Does this hit the same issue? If so, it's a permission/timing issue. If not, it's the specific command - but at least we'll have narrowed the problem down.
I don't know the corflags either, but it is using a file in the workspace (a file that is downloaded from Version Control). There is a readonly flag on this file by default.
So if you need this file to be writable:
1) either checkout the file if you need this file in your version control and afterwards check it in again (tf checkout / tf checkin)
2) remove the file from version control if the file is created by the app
3) remove the readonly flag with the attrib command.