Created
December 28, 2023 11:40
-
-
Save bukowa/c9aa19238b987254fcb90507a2cefd11 to your computer and use it in GitHub Desktop.
change visibility of all gitlab projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gitlab | |
# Replace these values with your GitLab information | |
gitlab_url = "https://gitlab.com" | |
private_token = "" | |
group_id = "" | |
# Create a GitLab API connection | |
gl = gitlab.Gitlab(gitlab_url, private_token=private_token) | |
# Fetch all projects in the specified group | |
group = gl.groups.get(group_id) | |
projects = group.projects.list(get_all=True) | |
# Change visibility of each project to private | |
for project in projects: | |
print(f"Changing visibility of project '{project.name}' to private...") | |
project.visibility = "private" | |
proj = gl.projects.get(project.id) | |
if proj.visibility != 'private': | |
proj.visibility = "private" | |
proj.save() | |
print("Visibility changed for all projects in the group.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment