Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,555,708
Community Members
 
Community Events
184
Community Groups

create repository from command line

Using a script how can I create a repository? My bitbucket server allows me to use these types of urls :

https://mybitbucket.com/rest/api/1.0/projects

 

I tried to use:

curl -s -u {user}:{passwd} -k --header "Content-Type: application/json" -X PUT "https://mybitbucket.com/rest/api/1.0/projects?name=newproj&permission=REPO_WRITE"

For this one the reply was: Oops, you've found a dead link

The path where a project already exists is: 

https://mybitbucket.com/scm/int/edep.git

Similarly I want to create a project named newproj

 

 

3 answers

More recently, we can just use bitbucket-cli.

Install it using pip

pip install bitbucket-cli

Then create a repo using

bitbucket create --private --protocol ssh --scm git YOUR_REPO_NAME

Note that this creates a private git repo, you can use --public for public access and --scm hg if you use Mercurial. Username argument can be added via --username YOUR_USER_NAME.

 

Thanks to Stephen

FYI as of Oct 27 2019 it appears that the APIs that `bitbucket-cli` uses are deprecated:  https://developer.atlassian.com/cloud/bitbucket/deprecation-notice-v1-apis/

Leading to this error: 

{"type": "error", "error": {"message": "Resource removed", "detail": "This API is no longer supported.\n\nFor information about its removal, please refer to the deprecation notice at: https://developer.atlassian.com/cloud/bitbucket/deprecation-notice-v1-apis/"}}
Like # people like this

Hi Christian,

 

I was trying with the below command.  Everything worked without error. But the repository was not created.

 

curl -s -u {username}:{password} -k --header "Content-Type: application/json" -X POST "https://mylocalrepository/rest/api/1.0/projects/{projectKey}?name=test2&permission=REPO_WRITE"

 

Could you please help me?

 

Thanks in advance,

Atul

Christian Glockner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Aug 13, 2022

Hi Atul,

I would recommend adding the -v option to the curl command, that should show you any error that occurs (curl hides them by default).

Cheers,

Christian

Premier Support Engineer

Atlassian

0 votes
Christian Glockner
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Sep 14, 2017

Hi Laci,

The reference for the REST API is located here. If you want to create a new project you'll need to use POST (instead of PUT) and pass the project data along in JSON format. PUT is used to update existing projects.

The same applies for creating repositories inside of projects.

Cheers,

Christian

Premier Support Engineer

Atlassian

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events