We are programmatically generating deployment emails, based on the history of changesets and associated workitems since the last deployed build. They look a bit like the build summary info inside Visual Studio (but with many builds combined).
There appear to be useful URLs in the data (like vstfs:///VersionControl/Changeset/205151), but being new to the TFS SDK I do not if/how this maps to a viewable item (e.g. http://tfsserver:port/somepath/...). The build summary links inside Visual Studio are clickable, but are they VS-only links?
If possible we want to include links in the email that open the related item (in a browser?), so I guess I need to know if TFS paths are web-browsable and if so, how?
Suggestions welcomed. Thanks.
This is the uRl i have been using to access work items,
=> http://ServerName:PortNumber/tfs/web/wi.aspx?id=xxidxx
Edit
The format i have specified does work with TFS 2010. It basically generates the path to the work item in Web view. Clicking on this opens the work item in the web view.
As an alternate, you could get a navigatable URL programmatically as well.
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("TFSURL"));
var versionControl = tfs.GetService<ICommonStructureService>();
var projects = versionControl.ListAllProjects();
var myService = tfs.GetService<TswaClientHyperlinkService>();
var myUrl = myService.GetChangesetDetailsUrl(21);
So, the service "TswaClientHyperlinkService" is microsofts TFS hyperlink service. This will generate the url formats for Absolute path, relative path, Path and Query, blah blah.
HTH,
Cheers, Tarun
PS - I hate to be wrong!!! hahaha...
EDIT
And since in your case you have the URI available and you already are using the TFS API, these two lines of code would do the trick.
var testManagementService = tfs.GetService<ILinking>();
var testControllers = testManagementService.GetArtifactUrl(#"vstfs:///VersionControl/Changeset/205151");
This will generate, https://ServerName:PortNumber/defaultcollection/VersionControl/Changeset.aspx?artifactMoniker=205151
HTH,
Cheers, Tarun
The following seems to be the standard url for accessing work items
http://TFS_Name:port_number/WorkItemTracking/Workitem.aspx?artifactMoniker=work_Item_Id
The vstfs links are called "artifact IDs" and are internal data to TFS that is expected to only be consumed by a TFS client. A TFS client will parse that data and determine how to display that data. For a changeset link like you provide, the rich clients will open up a dialog with the changeset details. A web client would translate that link into a URI. And the various TFS libraries are able to provide you more data on this artifact using that ID.
If you wanted to create your own link to TFS Web Access, the strictly proper way to do this is to query some information on the server. Once you have a TswaClientHyperlinkService, you can query for the Web Access URIs for various services, such as view a changeset or view a work item. Some examples are shown on Martin Woodward's blog.
In TFS2012, an additional pcguid URL parameter needs to be present. Here's the new format, extending the good solution given by #TarunArora:
http://ServerName:PortNumber/tfs/web/wi.aspx?pcguid=xxguidxx&id=xxidxx
This blog post describes how to find the pcguid via Visual Studio.
However, if like me you're attempting to use TFS without Visual Studio installed (don't ask!), here's an alternative using the browser-based TFS interface:
Go to "Open Issues"
Click on the button that looks like an envelope ("Send query as an email") in the top right of the work item pane.
Right-click on one of the links in the email and copy the link location
Cancel out of the email without sending it.
Paste link location into a text editor and extract the pcguid value.
Related
I am pulling a file from on premise TFS source control using the Rest API. I can't find on premise specific documentation, but it seems to be very close to version 4.1 of the Azure Get Item call. According to this documentaiton, it should return a TfvcItem object which has a lot of metadata including the version. However, when I make the call it only returns the file contents (the content field of the documentation's TfvcItem).
How do I get the current version of the file?
I need the version when I check itin with create changeset. I don't need it for any other reason, so if you know another way to check in an edited file that would help.
Instead of using Get Item API, some related REST APIs are not documented. For these REST APIs we can use tools such as Fiddler or directly press F12 - network in Chrome to track them.
You should use below API to fetch latest changeset version of a file:
post https://dev.azure.com/{organizationname}/{Projectname}/_api/_versioncontrol/history?__v=5
For body:
{"repositoryId":"","searchCriteria":"{\"itemPath\":\"$/MyFirstProject/Main/1.txt\",\"itemVersion\":\"T\",\"top\":50}"}
itemPath is your server path of the file.
From the response, you will get the version info such as "version": "139", instead of the file content.
Not sure your detail version of TFS, I was using Azure DevOps Service for an example. There maybe some difference for different TFS version. You could track the detail API on your own side.
More detail info kindly take a look at this question: VSTS Release API Documentation
Had the same issue. You can get item metadata by specifying "scopePath" URI parameter, instead of "path". Microsoft example in API documentation seems incorrect, as it indeed returns only item content: https://learn.microsoft.com/en-us/rest/api/azure/devops/tfvc/items/get?view=azure-devops-rest-6.0#get-item-metadata-and/or-content-for-a-single-item.
I'd like to show the Azure DevOps Wiki I created for my project within a WPF View with a Browser control. I used the following url:
https://dev.azure.com/xxx/xxx/_wiki/wikis/KIS.wiki?wikiVersion=GBwikiMaster&pagePath=%2FNew%20Features&pageId=1
Is it possible to show only the Wiki, without the DevOps main menu on the left side (Overview, Summary, Dashboards, Wiki, Repos, Pipelines, etc.)?
Is it possible to show only the Wiki, without the DevOps main menu on
the left side (Overview, Summary, Dashboards, Wiki, Repos, Pipelines,
etc.)
As you can see from this link, this is the link which represent the whole page contained the left panel and right content displayed. If you want to use this link as the part of your WPF view, it may not be shown only wiki.
But there has an work around, since WPF support Markdown language, you can use the below api to get the its markdown script:
https://dev.azure.com/{org name}/{project name}/_apis/wiki/wikis/{wiki name}/pages/%2F10
And then, use these to used into your WPF script.
Update:
To use this API, you need to pass the credential to the script first. To supply the credential, you can link a .cs file which written with C#.
In this .cs file, use the follow C# script to get connect with your org:
var url = new Uri("https://dev.azure.com//{org}");
VssCredentials cre = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "{PAT token}"));
var connection = new VssConnection(url, cre);
var workitemClient = connection.GetClient<xxxxHttpClient>();
Just wanted to share what we finally ended up with for our WPF "WikiView" user control:
we use the WikiHttpClient's GetPageAsync() to get all pages' content (page.Page.Content) and save the markdown (*.md) files locally using the path name in page.Page.GitItemPath
we use the GitHttpClient to get all images from the "attachments" folder within the wiki repository
Markdig to convert the markdown to html (and manually fix absolute link addresses to relative ones)
a ListBox for the wiki pages (table of contents)
a CefSharp browser control to show the html (the WPF BrowserControl displayed images too small)
I will supply some code in case that's of interest.
Given that the wiki is actually markdown, you can always download the source and use a markdown viewer. E.g. VsCode markdown preview.
I need to retrieve all work items in TFS 2015.2 using REST API
I have referred below link from Microsoft
https://www.visualstudio.com/en-us/docs/work/track/using-queries
Below is the similar url pattern I used,
http://fabrikam:8080/tfs/DefaultCollection/q.aspx?pname=FabrikamFiber&wiql=SELECT [System.ID], [System.Title], [System.State] FROM WorkItems WHERE [System.TeamProject]='FabrikamFiber' AND [System.WorkItemType]='Bug'
However this url end-up with nothing but error
Error
Error
The page you are looking for is currently unavailable.
TF400914: The specified team, q.aspx, either does not exist or you do not have access to it.
Please be kind enough to show some light to overcome this issue.
Note TFS 2015 require that you encode the WIQL portion of the URL syntax. You can use any URL encoder tool to encode your URL.
TFS 2015 syntax
https://{ServerName}/{CollectionName}/{TeamProjectName}/_workitems?_a=query&wiql={Encoded WorkItemQueryLanguage]
For example, the following hyperlink lists the ID, title, and state of all bugs under the FabrikamFiber/Web area path hosted on the fabrikam server and it's encoded url.
http://fabrikam:8080/tfs/DefaultCollection/FabrikamFiber/_workitems?_a=query&wiql=SELECT%20%5BSystem.ID%5D%2C%20%5BSystem.Title%5D%2C%20%5BSystem.State%5D%20FROM%20WorkItems%20WHERE%20%5BSystem.TeamProject%5D%3D'FabrikamFiber'%20AND%20%5BSystem.WorkItemType%5D%3D'Bug'%20AND%20%5BSystem.AreaPath%5D%3D'FabrikamFiber%5CWeb'%20%20
According to your url, seems you are still using TFS 2013 syntax, if you need to retrieve all work items in TFS 2015.2. Please use TFS2015 syntax instead.
If you need to retrieve all work items in TFS2013. The easiest way to define a hyperlink is to create a query that matches what you want and then copy the URL for the query. Create the same query in web portal/team explorer to narrow down the issue to see if you are able to get all work items. And copy the url directly to double check your url format.
I have installed TFS 2012 Express where I have a workspace with multiple solutions inside.
What I want to do is to create users to TFS for different solutions.
Lets say my solutions are
1-Provider
2-Mixer
3-Web
4-Control
I want to create a user who is only allowed to work on "Mixer" solution , and make changes to it. But dont want him to see other solutions("Provider" , " Web" , "Control") .
How can I do this ?
In Source Control Explorer, right click, Advanced, Security.
Deny the Read permission to the folder that contains the solution for all the users except those you want to see it.
You can also get to the security options via the Web Access under "Code" and right clicking.
I'm using the Team Foundation Server API to try to connect to a remote server.
From within my application, I try to connect to a URL of the form https://some-tfs-location.example.com/tfs but when doing so I get an error TF50309 (discussed here). If I add the project collection to the end of the URL (so the path becomes tfs/101) then I can connect with no problems.
I'd like to try and mimic the behaviour of Visual Studio, where I can give it a URL without needing to specify the project collection and it'll connect and locate the project collection.
Does anyone have any suggestions which API's I can use to mimic the Visual Studio behaviour? I had hoped to find the project collection via
TfsTeamProjectCollection ttpc = new TfsTeamProjectCollection(projectRoot.ServerUrl,new MyCredentials());
var projectCollection = ttpc.CatalogNode.FullPath;
But this results in the same TF50309 error code.
You can use the TfsConfigurationServer class with the server Uri that has no team project collection (e.g. http://localhost:8080/tfs), get the ITeamProjectCollectionService service, and use GetCollections method or GetDefaultCollection method to retrieve the collection you want.
This blog post described it in more details.