This repository contains a set of Python scripts to interact with GitLab. Below are the details for each script:
This script clones all repositories from a specified GitLab group, including those in subgroups, into a local directory.
- Python 3.x
python-gitlab
library
- Clone the repository.
- Install the required Python package:
pip install python-gitlab
- Set up the following variables in the script with your GitLab information:
GITLAB_URL = 'GITLAB_URL' # Your GitLab server URL AUTH_TOKEN = 'GITLAB_TOKEN' # Your GitLab private token GROUP_ID = 'GITLAB_GROUP_ID' # The ID of the GitLab group you want to clone DESTINATION_DIR = 'PATH_FOR_REPOSITORIES' # Path to the directory where repositories will be cloned
- Run the script:
python gitlab-clone-all-repositories.py
This script deletes all pipelines created by a specific user in a given GitLab project.
- Python 3.x
python-gitlab
library
- Clone the repository.
- Install the required Python package:
pip install python-gitlab
- Before running the script, update the following variables in the script with your GitLab information:
gitlab_url: The URL of your GitLab instance (e.g., https://gitlab.com). private_token: Your GitLab personal access token. project_id: The ID of the GitLab project where the pipelines should be deleted. username: The username of the user whose pipelines should be deleted.
- Run the script:
python gitlab-clone-all-repositories.py
This script fetches and clones all non-archived projects from a GitLab instance.
- Python 3.x
python-gitlab
libraryGitPython
library
- Clone the repository.
- Install the required Python package:
pip install python-gitlab GitPython
- Before running the script, update the following variables in the script with your GitLab information:
gitlab_url: The URL of your GitLab instance (e.g., https://gitlab.com). private_token: Your GitLab personal access token. project_id: The ID of the GitLab project where the pipelines details should be fetched. username: The username of the user whose pipelines details should be fetched.
- Run the script:
python gitlab-get-all-projects.py
This script updates GitLab CI variables for a specified project.
- Python 3.x
python-gitlab
library
- Clone the repository.
- Install the required Python package:
pip install python-gitlab
- Before running the script, update the following variables in the script with your GitLab information:
project_id: The ID of the GitLab project where the variables should be updated. token: Your GitLab personal access token. gitlab_url: The URL of your GitLab instance (e.g., https://gitlab.com).
- Run the script:
python gitlab-update-project-vars.py