I need to know which projects are part of a changeset for a specifc build using the VSTS API 2018. The REST api doesn´t seem to support getting a changeset based on a buildId. https://learn.microsoft.com/en-us/rest/api/vsts/tfvc/changesets/get
Is it possible to get a changeset based on a build ID?
Yes. You're looking at the wrong area of the documentation.
Ref: https://learn.microsoft.com/en-us/rest/api/vsts/build/builds/get%20build%20changes
GET
https://{accountName}.visualstudio.com/{project}/_apis/build/builds/{buildId}/changes?api-version=4.1
That gets you the changes associated with a build. If you want to get more details on the changesets from there, you can retrieve the specific changesets using the API you've already discovered.
Related
Imagine this:
You have an Azure DevOps 2019 server and a XAML Build definition.
You queue a few check-ins to the build definition. The first one is in progress of being checked in, the rest are waiting in queue.
How does one using the REST API get the shelvesets of the queued builds?
It's easy to get the shelveset associated with the InProgress build, because there's a BuildID present. I use it to get more details on the build using the API, e.g.: "Builds/33217/Details".
From there on, I can get to the shelveset.
If a build is queued (or NotStarted), then the build details API returns:
{
"value": [],
"count": 0
}
... and therefore I cannot get the shelveset.
I was under the impression that a upgrade to DevOps 2019 amends the API, so that one can easily get the queued shelveset from XAML build definitions as well. However, I'm not sure what I'm missing here. Should I be using another API?
Short answer ref Microsoft backlogged/doesn't exist/no easy way explained in option 1, but I used option 2, and option 3, I hope this helps you, I struggled a good bit!
Underlying issue is that you're querying from 1) Bottom to Top in DevOps build Hierarchy/Object Model, and you need to 2) Associate the shelveSets versioned changeSet & then to the build.
2. TLDR, I simply followed a practice of prefixing/Tags from my shelveSets allowing me to custom query the build as listed in option 3. This allowed me to simplify it a good bit in the REST API Query tagFilters={tagFilters} for e.g. ShelveSetBuildTag-....
// now modify you REST API filter `ShelveSetBuildTag-....`
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitions}&queues={queues}&buildNumber={buildNumber}
&tagFilters={tagFilters}&buildIds={buildIds}&repositoryId={repositoryId}&repositoryType={repositoryType}&api-version=6.0
Option 1: No example so, MS build docs was clear as mud for me, and was not helpful but its listed as possible, I gave up and took a different route, below..
Option 2:
since shelveSets are unversioned Azure DevOps uses versioned changeSets per their ER/DB Design , I had to get the associated shelveSets via ChangeSets/or WorkItems in a build.
First, a nice article I found to help me understand the relationship and difference between two key items, changeSet vs shelveSet Azure DevOps in relation to a build. The changeSet will allow you to find associated shelvesets to build, query it and get DimChangeset, I suspect you have to do this in a couple of steps.
picture below is associated with the following dimension tables:
DimBuild
DimChangeset
DimPerson
DimTeamProject
IMHO versioning allows you get your changeset associated with a build, and then you can get the shelveset that went into that changeset
Step 1: get changetSets for a ShelveSet
GET https://dev.azure.com/fabrikam/_apis/tfvc/shelvesets/changes?shelvesetId=My first shelveset;d6245f20-2af8-44f4-9451-8107cb2767db&api-version=6.0
Step 2: get
GET the changes in a build
https://{instance}/DefaultCollection/{project}/_apis/build/builds/{buildId}/changes?api-version={version}
Step 3: I manually join the Response in my middle ware
option 3:
Follow a practice of tagging your shelveSets
Then, you query, using tags filer: tagFilters={tagFilters} in your build query
Use the tags from your shelvesets and filter from your builds list tagFilters={tagFilters} , of course this assume you setup tags
// ``tagFilters={tagFilters}``for your shelveset assuming you set those up
GET https://dev.azure.com/{organization}/{project}/_apis/build/builds?definitions={definitions}&queues={queues}&buildNumber={buildNumber}&minTime={minTime}&maxTime={maxTime}&requestedFor={requestedFor}&reasonFilter={reasonFilter}&statusFilter={statusFilter}&resultFilter={resultFilter}&tagFilters={tagFilters}&properties={properties}&$top={$top}&continuationToken={continuationToken}&maxBuildsPerDefinition={maxBuildsPerDefinition}&deletedFilter={deletedFilter}&queryOrder={queryOrder}&branchName={branchName}&buildIds={buildIds}&repositoryId={repositoryId}&repositoryType={repositoryType}&api-version=6.0
I am looking for a way to produce all TFS Work Items from a Jenkins promote job.
We have an on prem deployment of TFS with service hooks in place to build the corresponding applications on check-in. The changeset Id is included with the notification, but I need the TFS work item for that Changeset.
More importantly - we will have several builds run; each with a singular changeset before we actuall run the promotion job.
What I would like to do is find a way to produce the list of TFS work items between releases. Looking a plug-in or tool that will help produce this.
Update
You should first get the built changeset info in Jenkins side.
There seems to be a build.changeSets variable which could retrieve all the changeset.
Then you could directly use rest api in TFS to query work items info from changeset ID. Detail steps kindly take a look at here: How to retrieve work items associated to a build in jenkins with pipeline?
According to your description, seems you just want to get all work items between releases (for example: the current release and a previous release).
Retrieve work items by calling
https://{account}.vsrm.visualstudio.com/[teamproject]/_apis/Release/releases/{current release id}/workitems?api-version=4.1-preview.1&baseReleaseId={release id}
It just return the id, url of work items, and then you need to get details of work item through Get a list of work items REST API.
I have a requirement to assign a VSTS bug item to be fixed in next release using VSTS Rest API. I'm assuming "Microsoft.VSTS.Build.IntegrationBuild" is the field to update with next release version. However this field is not available in VSTS bug item UI(Build and test integration field reference). I also need to retrieve the next release information for the project via VSTS API, Is it possible to do this with current VSTS Rest API? Please advice.
Thanks in advance.
There isn’t the REST API to link bug work item to release. Also, we can’t to do it through UI (e.g. web access)
The work item be linked to the build can be track in the release. So you can link work item to changeset (REST API or manually), then the build associate to this changeset will associate that work item.
I'm using VSTS for my Nightly/CI builds.
VSTS pulls the code from TFS repository.
I noticed that triggering the build against (specific changeset E.g.'33333', 'C33333') returns
"BadRequest 400 The value specified for SourceVersion is not a valid version spec."
Microsoft.TeamFoundation.Build.Server.BuildRequestValidationFailedException
When changeset is not specified everything works fine.
Did anyone had this problem?
I have a request to Microsoft.
They know about this bug. This issue will be fixed this week.
You mean Team Foundation Version Control repository type. Based on my test with VSTS, I can reproduce that issue, the same as REST API.
You can vote this feedback (https://connect.microsoft.com/VisualStudio/feedback/details/3102566/specifying-a-source-version-in-vsts-returns-a-400-bad-request) and track update of VSTS.
Is it possible to filter changesets in TFS 2012 to exclude the ones from a single user?
The commit history of the solution I currently work on contains quite a lot of noise due to an automated process making a commit each time a build is queued.
I'd like to filter it out to make the commit history more readable.
An alternative, try to install Team Foundation Sidekicks, and check History Sidekick. You can export the records to a .csv file and then filter the user in it:
There is no single query can achieve what you need. You may have to use TFS API.
If you want to get the changesets in a solution via TFS API. The folder history will be the simplest approach. Details please refer this: TFS client C# API - get all changesets of an Item You can exclude those changesets from the special user using Changeset.Committer Property which gets the user who committed the changeset.