Hello, I am trying to initialise a repository via REST API and can't seem to find the right endpoint.
I have managed to:
How can I initialise the repository using only the REST API straight after creating the repository?
Hi @maweeks,
Can you let us know what is not possible to automate at the moment?
Is it about adding the source code, in other words pushing the git repository?
I see that you have been able to identify the REST API to perform various the initial creation and apply various configuration.
Cheers,
Caterina - Atlassian
Hello,
I am currently unable to make the initial commit to a repository in a project on bitbucket server.
I can create the repository but I am unable to commit any changes without a branch to reference.
I know on bitbucket.org I can use a POST to:
https://api.bitbucket.org/2.0/repositories/username/zzz/src/
without specifying a branch and it will create the master branch.
But I am unable to find the same functionality on bitbucket server for a repository in a project.
Current calls:
Bitbucket.org:
Create repository - works as expected
POST - https://api.bitbucket.org/2.0/repositories/username/zzz
body = {
"name": "zzz test",
"scm": "git"
}
Create README.md / initial commit: - works as expected
POST - https://api.bitbucket.org/2.0/repositories/username/zzz/src/
body = x-www-form-urlencoded
/README.md = # zzz repository
Create file once a branch exists: - works as expected
POST - https://api.bitbucket.org/2.0/repositories/username/zzz/src/
body = x-www-form-urlencoded
/Y.md = testData
Bitbucket server:
Create repository: - works as expected
POST - %{base_url}/rest/api/1.0/projects/%{project}/repos
body = {
"name": "zzz test",
"scmId": "git"
}
Create README.md / initial commit: - NEEDED
Create file once a branch exists: - works as expected
PUT - %{base_url}/rest/api/1.0/projects/%{project}/repos/%{repository}/browse/Y.md
body = x-www-form-urlencoded
branch = master
content = testData
message = SecondCommit
%{base_url}/rest/api/1.0/projects/%{project}/repos/%{repository}/browse/* cannot be used without specifying a branch and specifying master doesn't work as it doesn't exist initially.
Is there a way to either initialize the repository with the master branch / README in the create repository call, or is there another REST call that I can use to make the initial commit like I do on bitbucket.org?
(I realize that I could script the clone, commit, push but would rather not do that if I can do it via a REST call.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any luck with this issue ?
I(m trying to do the exact same stuff and no way to create a branch because :
repo is empty - branches cannot be created in empty repositories.
but no way to make a first commit ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.