如何使用单个脚本克隆所有git bitbucket存储库

时间:2017-08-16 06:35:19

标签: git bash rest bitbucket

如何使用bash脚本检查团队的所有git bitbucket存储库?

此主题还有其他问题,但这些答案中提到的bitbucket api不再存在。

4 个答案:

答案 0 :(得分:2)

以下脚本将克隆项目的所有存储库:

for r in $(curl -s --user USER:PASS --request GET https://BITBUCKET-SERVER/rest/api/1.0/projects/PROJECT/repos | jq --raw-output '.values[].links.clone[].href')
do
    git clone $r
done

答案 1 :(得分:0)

我在nodeJS中编写了这个small project,它支持GitHub和Bitbucket Cloud。

答案 2 :(得分:0)

我在此处提供了一个简单的脚本:per the docs 它的工作原理与Marcelo的答案相似,但是它使用bitbucket上的api来获取它们。 它也具有jq作为依赖项。

答案 3 :(得分:0)

以下脚本可以很好地从 Bitbucket 下载所有存储库。

  1. 用户名不是电子邮件

  2. 从 Bitbucket 创建应用密码

  3. 通过sh script.sh运行脚本

     #!/bin/bash
    
     user=username:password
    
     curl -u $user 'https://api.bitbucket.org/2.0/user/permissions/teams?pagelen=100' > teams.json
    
     jq -r '.values[] | .team.username' teams.json > teams.txt
    
     for team in `cat teams.txt`
     do
       echo $team
    
       rm -rf "${team}"
    
       mkdir "${team}"
    
       cd "${team}"
    
       url="https://api.bitbucket.org/2.0/repositories/${team}?pagelen=100"
    
       echo $url
    
       curl -u $user $url > repoinfo.json
    
       jq -r '.values[] | .links.clone[0].href' repoinfo.json > repos.txt
    
       for repo in `cat repos.txt`
       do
         echo "Cloning" $repo
         git clone $repo
       done
    
       cd ..
    
     done