Skip to content

Instantly share code, notes, and snippets.

@btmash
Created October 24, 2023 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save btmash/6d9d16cae9723806536504b5f4ba0864 to your computer and use it in GitHub Desktop.
Save btmash/6d9d16cae9723806536504b5f4ba0864 to your computer and use it in GitHub Desktop.
Get all repos from AWS Codecommit (with optional capability to use parallel if your system has it)
#!/bin/bash
REPOSITORIES=$(aws codecommit list-repositories --sort-by repositoryName --query 'repositories[].repositoryName' --output text)
if ! command -v parallel &> /dev/null
then
for REPO in $REPOSITORIES
do
bash ./get_repo.sh $REPO
done
else
parallel -j 4 bash ./get_repo.sh {} ::: $REPOSITORIES
fi
#!/bin/bash
if [ -z "$1" ];
then
echo 'No repository name supplied'
exit 1
fi
REPO=$1
echo $REPO
DETAILS=$(aws codecommit get-repository --repository-name $REPO)
REPONAME=$(echo $DETAILS | jq '.repositoryMetadata.repositoryName' | tr -d '"')
REPO_SSH_PATH=$(echo $DETAILS | jq '.repositoryMetadata.cloneUrlSsh' | tr -d '"')
rm -rf $REPONAME
git clone $REPO_SSH_PATH $REPONAME
echo $REPONAME
echo $REPO_SSH_PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment