This PowerShell script interacts with the GitLab API to manage projects within a specified group. It allows you to clone repositories and update them based on specified branch names.
- Retrieve GitLab groups and projects using the GitLab API.
- Clone repositories if they are not already cloned.
- Checkout specified branches and pull the latest changes.
- PowerShell installed on your system.
- Git installed and available in your system PATH.
- A valid GitLab account with the necessary permissions.
- Clone the Script: Download the script to your local machine.
- Run the Script: Execute the script in PowerShell.
.\script.ps1
The script prompts for the following information:
- GitLab Host: The base URL of your GitLab instance (e.g.,
https://git.example.com
). - GitLab Access Token: A personal access token with the appropriate permissions (e.g.,
glpat-*****
). - GitLab Group ID: The ID of the group whose projects you want to manage.
GitLab Host (example: https://git.example.com)
GitLab Access Token (glpat-*****)
GitLab Group Id (Press return key if you don't know what group id is)
The script includes error handling for various scenarios:
- Invalid GitLab Host: If an invalid host is provided, the script will terminate.
- Missing Access Token: Prompts the user for a valid access token.
- Invalid Group ID: If the provided group ID is invalid, it displays available groups.
- Unauthorized Access: If the access token is invalid (401 error), the script prompts to provide a valid token and opens the token generation page.
- The script checks if each project is already cloned. If not, it clones the repository.
- It attempts to checkout specified branches (e.g.,
master
,main
) and pulls the latest changes. If no matching branches are found, it skips the project.
The script will output messages indicating the status of cloning and updating repositories, along with any errors encountered.
This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to adjust any parts or add specific details relevant to your project! If you need further modifications or additional sections, just let me know.