I've created a repository in BitBucket using the api:
curl -v -X POST -d '{"scm": "git", "is_private": "true", "fork_policy": "no_forks", "project": {"key": "MARS"}}' -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/myteam/test -u <user-name>
How can I set user-access roles for the new repository?
Specifically I want to set a group TeamAdmins to have admin privileges
Answered by Bitbucket team, but maybe someone will look for this:
There is currently no support for this in api-2, and no current due date on the feature.
You can do this using API-1: using privileges-endpoint
Related
I used to do
curl -k -X POST --user john#outlook.com:doe13 "https://api.bitbucket.org/1.0/repositories" -d "name=logoApp"
and success.
now I got : 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/"}}
Does anyone know a know way to do this ?
There's a difference between a success from curl (OK:200) and an error from the service you're trying to use. The error, however, mentions that you're trying to use the Cloud Rest API version 1, which is deprecated effective 30 June 2018.
Read this for more information.
I don't use Bitbucket Server (a local option), and I think that has more features for this sort of thing.
For the public Bitbucket, you can still do it but it isn't documented.
The v1.0 API has been removed, and the new v2.0 API doesn't document a POST to a /repositories. Instead, you have to hit an endpoint that includes the repo that doesn't yet exist: /repositories/workspace/repo_slug
The JSON payload needs to know the project for the repo: look in the slug for a project that already exists. Fill in the user/team and repo name in the URL. And, you can make an application password so you aren't using your account password. This app password can limit the scope of what that access can do.
% curl -X POST --user 'user:app_pass' \
-H "Content-type: application/json" \
-d '{"project":{"key":"PROJ"}}' \
"https://api.bitbucket.org/2.0/repositories/USER/REPO"
I see the docs for updating the build status for a commit:
https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/commit/%7Bnode%7D/statuses/build
For a pull request, isn't there a unique commit associated with it? Is there no API for updating a PR's build status? Or do we just need to discover which commit is associated with the PR, and then just update the build status for that commit?
For example this view:
You can see on the right that the commit to the temp branch has a passing build status - but the way it works is it should merge temp into master into some new commit/branch and I need to be able to test that.
The view that I want to update is at url:
https://bitbucket.org/<user>/<repo>/pull-requests/1/<commit-message>/diff
Bitbucket does not have Builds on PRs (Check here), What you need is one Successful Build on the LAST Commit:
Then, you can use the API to push the build to that one after you have done what you need to test it.
This guide is really simple to use:
https://developer.atlassian.com/server/bitbucket/how-tos/updating-build-status-for-commits/
👆The only recommendation I have on the guide is that it didn't work for me with curl, then, what I did was to do it with Postman and then exported the command to curl and that's it...
curl --location --request POST 'https://bitbucket.org/api/2.0/repositories/{your space}/{Your Repo}/commit/{The long hash of your commit}/statuses/build?Content-Type=application/json' \
--header 'Authorization: Basic {your token}=' \
--header 'Content-Type: application/json' \
--data-raw '{
"state": "SUCCESSFUL",
"key": "MANUAL-BUILD",
"name": "Manual Build",
"url": "http://this.really.doesnt.matter/",
"description": "Successful Build done manually"
}'
Just go to this this url and type "build" and you will find the relevant routes:
Has anyone been able to use the WebSphere Liberty REST API to deploy remote Docker containers? The docs describe all the steps, but I am not able to repeat the results. I get an error when calling REST deploy function (details are posted on the other forum).
If anyone was able to do it - please let me know and would be great if you share how you were able to do it.
Not long after posting this question I tried using the curl command with the JSON header spec and now it works. Here is the curl command I am using that works:
curl --verbose --insecure -X POST --data #docker_deploy.json --header "Content-Type: application/json" -u ${ADMIN_USER}:${ADMIN_PASSWORD} https://${CONTROLLER_HOST_NAME}:${CONTROLLER_PORT}/ibm/api/collective/v1/deployment/deploy
I found Using BitBucket's API to fork a repository and this is helpful in so far as letting me know that creating a fork is possible.
However I want to create the fork in a certain project on the bitbucket server.
We have a use case where we want to create a fork of some repositories in another project and then merge back only the parts of the project that are re-usable not the project specific stuff.
Assuming you want to fork PRJ1/repo_AA as PRJ2/repo_BB, you can use:
curl -X POST -H 'Content-Type: application/json' \
-d '{ "slug": "repo_BB", "name": "repo_BB", \
"project": { "key": "PRJ2" } }' \
https://your.serv.er:7990/rest/api/1.1/projects/PRJ1/repo_AA
Be sure project PRJ2 already exists (you can create it via REST API as well) and have the correct credentials.
HTH
Regards
I couldn't find anything even remotely related in the documentation.
Using the Bitbucket website you can rename a repo as follows:
Go to the repo's overview page, usually https://bitbucket.org/username/oldname/overview
Click the settings cog on the far right end of the menu row !
Instead of 1. and 2. you can type 'r' then 'a' for administration.
Change the name in the Name field.
Click Save repository details.
Be advised that changing the name of the repo will change its URL access too. Previously the access was https://username#bitbucket.org/username/oldname.git Now, however, the repo's URL/Path will be https://username#bitbucket.org/username/newname.git
You can check this by going back to the Overview page, and hovering over the big blue HTTPS button. The bottom of your browser will show that it now points to https://username#bitbucket.org/username/newname.git
If you are using SourceTree you can update the remote's URL by highlighting the local repo in SourceTree and then
Click Repository
Click Repository Settings...
Highlight the row containing the remote branch. Usually origin https://username#bitbucket.org/username/oldname.git
Click Edit
Update the URL/Path field. Change 'oldname.git' to 'newname.git', leave the rest unchanged. So the full path should be https://username#bitbucket.org/username/newname.git
Click OK
For version 2.0 of the API:
According to https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-put
PUT https://api.bitbucket.org/2.0/repositories/{workspace}/{repo_slug} --data "{\"name\": \"${new_name}\"}"
Using the PUT method allows renaming of a repository.
For version 1.0 of the API:
According to https://confluence.atlassian.com/display/BITBUCKET/repository+Resource+1.0:
PUT https://api.bitbucket.org/1.0/repositories/{accountname}/{repo_slug} --data "name=new name"
This allows to update the visible name of a repository.
In a unix shell you can use cURL;
curl https://api.bitbucket.org/1.0/repositories/{accountname}/{old_repo_name} --data "name=new_repo_name" -X PUT
Is it possible for a user to authenticate in private repositories, but still have only administrators able to execute:
curl https://USER:PASS#api.bitbucket.org/1.0/repositories/{accountname}/{old_repo_name} --data "name=new_repo_name" -X PUT
Just in case anyone hits this with looking for a solution to an old version of the bitbucket API (in my case 5.14.0) to say the documentation on this version is lacking is being quite polite.
curl --location --request PUT 'https://git.local.install/rest/api/1.0/projects/aa/repos/my-repo' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic .....' \
--data-raw '{"name":"my-new-name"}'
According to the lastest API here is the correct curl command:
curl -X PUT --user username:password https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug} --data "name=newRepoName"
Note that the repo_slug is the repository name IN LOWER CASE. If you don't put it all in lower case you would get the not so expressive answer "Not Found".
If you are not sure what is the repository slug execute the following command, which shows you the user's information including current repositories, and look for the field "slug"
curl --user username:password https://bitbucket.org/api/1.0/user