我有一个项目,在我的藏匿处内有大约30个存储库。我稍微摆弄了一下,现在我想重置一切并重新导入它们。据我所见,没有办法在Stash中“清理”存储库,所以我决定删除它们并再次创建它们。由于有一堆存储库,这可能不是我最后一次这样做,我真的很感谢一次删除/创建多个存储库的方法,因为我需要相当长的时间通过前端手动执行此操作。有谁知道,如果可能的话?
答案 0 :(得分: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
或类似的东西
答案 1 :(得分:0)
通过可以访问你的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;