I am using Atlassian Stash (Bitbucket server) to manage my git repository. Recently I had a requirement to commit a file (a newly created .xml file) to my Git repository using the Stash REST API. I've gone through the documentation, but it seems like the REST API doesn't support that functionality.
Am I correct, or is this possible somehow?
Probably you are looking for
PUT /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}
From the documentation of API
PUT /rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/browse/{path:.*}
Update the content of path, on the given repository and branch. This resource accepts PUT multipart form data, containing the file in a form-field named content. An example curl request to update 'README.md' would be:
curl -X PUT -u username:password -F [email protected] -F 'message=Updated using file-edit REST API' -F branch=master -F sourceCommitId=5636641a50b http://example.com/rest/api/latest/projects/PROJECT_1/repos/repo_1/browse/README.md
- branch: the branch on which the path should be modified or created
- content: the full content of the file at path message: the message associated with this change, to be used as the commit message. Or null if the default message should be used.
- sourceCommitId: the commit ID of the file before it was edited, used to identify if content has changed. Or null if this is a new file.
The file can be updated or created on a new branch. In this case, the sourceBranch parameter should be provided to identify the starting point for the new branch and the branch parameter identifies the branch to create the new commit on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With