Reputation: 95
I want to get all the files present for a particular commit Id in bitbucket server using rest API. Is there any api to get the complete data ?
Upvotes: 0
Views: 2135
Reputation: 11234
Based on the api doc here : https://docs.atlassian.com/bitbucket-server/rest/7.7.1/bitbucket-rest.html#idp228
you can use
/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/commits/{commitId}/changes
Sample Response looks like:
{
"size": 1,
"limit": 25,
"isLastPage": true,
"values": [
{
"contentId": "abcdef0123abcdef4567abcdef8987abcdef6543",
"fromContentId": "bcdef0123abcdef4567abcdef8987abcdef6543a",
"path": {
"components": [
"new",
"path",
"to",
"file.txt"
],
"parent": "new/path/to",
"name": "file.txt",
"extension": "txt",
"toString": "new/path/to/file.txt"
},
"executable": false,
"percentUnchanged": 98,
"type": "MOVE",
"nodeType": "FILE",
"srcPath": {
"components": [
"path",
"to",
"file.txt"
],
"parent": "path/to",
"name": "file.txt",
"extension": "txt",
"toString": "path/to/file.txt"
},
"srcExecutable": false,
"links": {
"self": [
{
"href": "http://link/to/restchange"
}
]
}
}
],
"start": 0
}
Upvotes: 0
Reputation: 1
By the way: the "at" parameter exists also here (so no need to use the "archive" endpoint to stream a zip file):
/api/latest/projects/{projectKey}/repos/{repositorySlug}/files/{path}?at={commitId}
Documentation here:
Upvotes: 0
Reputation: 124
Hi you can use this..
rest/api/1.0/projects/{projectname}/repos/{reponame}/commits/{commit id}/changes
The reply will contain (among other information) the details of each files modified in the commit.
As an example, this is the related section from the entire json output:
path: {components: ["file1.txt"],parent: "",name: "file1.txt",extension: "txt",toString: "file1.txt"},
Upvotes: 1
Reputation: 710
You are looking for this endpoint: https://docs.atlassian.com/bitbucket-server/rest/6.4.0/bitbucket-rest.html#idp178
GET /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/archive?at={commitId}
With this you will get in default a zip file with all the files at this specific commit. Following the link you can get more information about the endpoint.
Upvotes: 0