-
-
Save eeichinger/c2eb46fbe7d5e2f49eba3bfaf5471759 to your computer and use it in GitHub Desktop.
# generate a script ./clone-repos.sh from a list of repos fetched via Bitbucket API | |
# note: requires 'curl' and 'jq' to be installed | |
set -e | |
echo -n '' > clone-repos.sh | |
chmod +x clone-repos.sh | |
ONPREM_USER=xxxxx | |
ONPREM_PASS=...... | |
ONPREM_PROJECT=MYINTPROJ | |
curl -s -u "$ONPREM_USER:$ONPREM_PASS" https://bitbucket.mycompany.internal/rest/api/1.0/projects/$ONPREM_PROJECT/repos/\?limit=1000 | jq -r '.values[] | {slug:.slug, links:.links.clone[] } | select(.links.name=="ssh") | "git clone \(.links.href) \(.slug)-server"' >> clone-repos.sh | |
ORG_USER=yyyyyy | |
ORG_PASS=....... | |
ORG_PROJECT=MYCLOUDPROJ | |
ORG_TEAM=myteam | |
curl -s -u "$ORG_USER:$ORG_PASS" https://api.bitbucket.org/2.0/repositories/$ORG_TEAM/\?\q="project.key=\"$ORG_PROJECT\"" | jq -r '.values[] | {slug:.slug, links:.links.clone[] } | select(.links.name=="ssh") | "git clone \(.links.href) \(.slug)-cloud"' >> clone-repos.sh | |
# run the generated script | |
./clone-repos.sh |
I've built a cli for cloning and pulling git repos from bitbucket server
https://github.com/jensim/bitbucket_server_cli
How to create a create a repository under specific project key in bitbucket server using Git bash?
I am trying the below script.
curl -X POST -v -u $username:$password http://localhost:7990/rest/api/1.0/projects/$project_key/repos -H "Content-Type: application/json" -d "{\"name\": \"$FOLD_PATH\",\"scmId\": \"git\", \"forkable\": true }"
But it is not working. Can anyone suggest any answer? Thanks in advance.
How to create a create a repository under specific project key in bitbucket server using Git bash?
I am trying the below script.
curl -X POST -v -u $username:$password http://localhost:7990/rest/api/1.0/projects/$project_key/repos -H "Content-Type: application/json" -d "{\"name\": \"$FOLD_PATH\",\"scmId\": \"git\", \"forkable\": true }"
But it is not working. Can anyone suggest any answer? Thanks in advance.
You used the verbose flag, but what was the error output?
https://docs.atlassian.com/bitbucket-server/rest/7.10.0/bitbucket-rest.html#idp174
You did not provide a default branch name, not sure if thats needed though
The authenticated user must have PROJECT_ADMIN permission for the context project to call this resource.
Were you using a project_admin-user?
Using token generated via your user settings instead of username password option.
Yeah two options, basic or token