2

我有一个项目,我的存储库中有大约 30 个存储库。我摆弄了一下它们,现在我想重置所有内容并重新导入它们。据我所知,没有办法在 Stash 中“清理”存储库,所以我决定删除它们并重新创建它们。由于有很多存储库,而且这可能不是我最后一次这样做,我非常感谢一次删除/创建多个存储库的方法,因为我需要相当多的时间通过前端手动执行此操作。有谁知道,如果这可能吗?

4

2 回答 2

2

在这里隐藏开发人员。我还没有在 Marketplace 上看到可以做到这一点的插件。使用我们的REST api的简单 bash 脚本是否适合您?

for path in 'projectA/repos/repoA' 'myprojectB/repos/myrepoB' 'somethingC/repos/somethingC'; do curl -X DELETE --user username:password http://host:port/rest/api/1.0/projects/$path; done

或类似的东西

于 2013-11-22T20:04:50.933 回答
1

通过可以访问您的 stash/bitbucket 主机的 linux 机器,我想出了以下脚本:

#!/bin/bash
USER='someUser'
PASS='secretPassWord'

sudo apt-get -qq install jq curl
TMP=/tmp/PROJECTS.TO.DELETE.$RANDOM

# Get a list of all Projects
curl -k -s --user $USER:$PASS "https://stashHost/rest/api/1.0/projects/?limit=10000" | jq -r ".values[].key" | sort >$TMP

# Allow an opertunity to remove some projects from this deletion process
nano $TMP

# Loop through the remaining projects listed in the $TMP file and remove all repo's and projects.
for P in $(cat $TMP); do
        echo "Project: $P"
        for R in $(curl -k -s --user $USER:$PASS "https://stashHost/rest/api/1.0/projects/$P/repos?limit=10000" | jq -r ".values[].slug" | sort);
        do
                # Delete the repository
                OUTPUT=`curl -k -s -X DELETE --user $USER:$PASS "https://stashHost/rest/api/1.0/projects/$P/repos/$R" | jq -r ".message"`
                printf "Deleting: %10s\t%40s\t%s\n" $P $R "$OUTPUT"
        done;
        # Delete the empty project (with no remaining repos)
        curl -k -s -X DELETE --user $USER:$PASS "https://stashHost/rest/api/1.0/projects/$P";
done;
于 2016-09-08T15:41:56.480 回答