I am just starting out with GitLab and my boss asked me to use GitLab CI to initiate a pipeline which goes to a group/subgroup then clones everything inside, project files, subgroups, child projects and subgroups, until the end of the path. I am using the -gitlab-ci.yml in an empty project repo to try do this not lined to either the source or destination group. I keep getting stuck with host verification errors when pushing to the destination group. I know my method for accessing the source subgroup works fine because I can echo out what's inside and I can read it in the job execution log. I added my code below for reference, I would appreciate the help. I keep getting stuck with host verification
stages:
- list_files
variables:
SOURCE_GROUP_ID: "########"
DESTINATION_GROUP_ID: "########" # Replace with your destination group ID
ACCESS_TOKEN: $GROUP_ACCESS_TOKEN
list_files:
stage: list_files
before_script:
- apt-get update -y
- apt-get install -y jq
- git config --global user.email $MY_EMAIL
- git config --global user.name $MY_USER_NAME
script:
- |
function list_subgroups_and_projects {
local source_group_id=$1
local destination_group_id=$2
local source_group_name=$(curl --header "PRIVATE-TOKEN:$ACCESS_TOKEN" "https://gitlab.com/api/v4/groups/$source_group_id" | jq -r '.name')
echo "Subgroups and projects in group: $source_group_name"
# List projects in current group
echo "Projects in group $source_group_name:"
projects=$(curl --header "PRIVATE-TOKEN:$ACCESS_TOKEN" "https://gitlab.com/api/v4/groups/$source_group_id/projects" | jq -r '.[].ssh_url_to_repo')
for project in $projects; do
echo "Cloning project: $project"
git clone $project;
project_name=$(basename $project .git)
pushd $project_name
echo "Pushing project $project_name to destination group"
git remote set-url origin [email protected]:$DESTINATION_GROUP_ID/$project_name.git
git push origin master
popd
done
# List subgroups
echo "Subgroups in group $source_group_name:"
subgroups=$(curl --header "PRIVATE-TOKEN:$ACCESS_TOKEN" "https://gitlab.com/api/v4/groups/$source_group_id/subgroups" | jq -r '.[].id')
for subgroup_id in $subgroups; do
list_subgroups_and_projects $subgroup_id $destination_group_id
done
}
- list_subgroups_and_projects "$SOURCE_GROUP_ID" "$DESTINATION_GROUP_ID"
Please help me with finding a solution to the host verification failure.