This is how to clone and zip all sub repositories from bit bucket into a single zip fil

#!/bin/bash

# Configuration
WORKSPACE="your-workspace-name"          # Replace with your Bitbucket workspace name
PROJECT="CHE"                            # Replace with the project or folder name in Bitbucket
BITBUCKET_API="https://api.bitbucket.org/2.0"
ACCESS_TOKEN="your-access-token"         # Replace with your Bitbucket personal access token
DEST_FOLDER="CHE"                        # Destination folder for cloned repositories

# Create destination folder
mkdir -p "$DEST_FOLDER"

# Fetch repositories from Bitbucket
echo "Fetching repositories from Bitbucket workspace '$WORKSPACE', project '$PROJECT'..."
REPO_URLS=$(curl -s -H "Authorization: Bearer $ACCESS_TOKEN" \
    "$BITBUCKET_API/repositories/$WORKSPACE?q=project.key=\"$PROJECT\"" | \
    jq -r '.values[] | .links.clone[] | select(.name == "https") | .href')

# Check if any repositories were found
if [ -z "$REPO_URLS" ]; then
    echo "No repositories found for project '$PROJECT' in workspace '$WORKSPACE'."
    exit 1
fi

# Clone each repository
echo "Cloning repositories..."
for REPO_URL in $REPO_URLS; do
    REPO_NAME=$(basename "$REPO_URL" .git)
    echo "Cloning $REPO_NAME..."
    git clone "$REPO_URL" "$DEST_FOLDER/$REPO_NAME"
done

echo "All repositories have been cloned into the '$DEST_FOLDER' folder."