Replies: 1 comment 2 replies
-
You were almost there. The error message points you to the FAQ, and the entry you're looking for is this: You need to create a Project object, you cannot manipulate a GroupProject object directly. You can create a lazy object to save API calls. See: import os
import gitlab
GIT_URL = os.getenv("GIT_URL", "your_gitlab_url")
PRIVATE_TOKEN = os.getenv("PRIVATE_TOKEN", "you_token")
client = gitlab.Gitlab(GIT_URL, private_token=PRIVATE_TOKEN)
# Define a group under which all project are the project you want to archive
group_name = 'my_group_name'
group = client.groups.get(group_name)
# Archive all projects in the group
for group_project in group.projects.list(get_all=True):
project = client.projects.get(group_project.id, lazy=True)
# project_id = project.id
# project_name = project.name
# print(project_id, project_name)
try:
project.archive()
except Exception as e:
print(e) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I want to archive a group's all projects,But get error:
python3 codes is here:
what's wrong with it?
Beta Was this translation helpful? Give feedback.
All reactions