Reputation: 11
The Bitbucket Server API documentation outlines an endpoint to submit a PUT request and edit a file within a specified repository. However, the Bitbucket Cloud API does not seem to have this same functionality included.
Is there a direct or indirect way to edit a file using Bitbucket Cloud API?
My specific use case is to bump the version number specified within a build pipeline YAML file each time a successful Production release happens.
The current Python template provided for the Bitbucket Server API is as follows:
import requests
import json
url = "http://{baseurl}/rest/api/latest/projects/{projectKey}/repos/{repositorySlug}/browse/{path}"
headers = {
"Accept": "application/json"
}
response = requests.request(
"PUT",
url,
headers=headers
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
However, the Cloud API base URL is obviously different and it will not work.
Upvotes: 1
Views: 619
Reputation: 11
The work around for this on the Bitbucket Cloud API was to:
GET the original file that I want to edit
Write the contents of this file to a new empty file with the same name
Edit the contents of the file to suit my needs
POST the edited file (Posting a file with the same name to the same location causes an overwrite of the original)
Things to note:
Upvotes: 0