Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AttributeError: 'GroupProject' object has no attribute 'archive'#2549

ayunwSky started this conversation inGeneral
Discussion options

I want to archive a group's all projects,But get error:

https://python-gitlab.readthedocs.io/en/v3.14.0/faq.html#attribute-error-list'GroupProject'objecthasnoattribute'archive'<class'gitlab.v4.objects.projects.GroupProject'>wascreatedviaalist()callandonlyasubsetofthedatamaybepresent.Toensurealldataispresentgettheobjectusingaget(object.id)call.Formoredetails,see:https://python-gitlab.readthedocs.io/en/v3.14.0/faq.html#attribute-error-list

python3 codes is here:

importosimportgitlabGIT_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 archivegroup_name='my_group_name'group=client.groups.get(group_name)# Archive all projects in the groupforprojectingroup.projects.list(get_all=True):# project_id = project.id# project_name = project.name# print(project_id, project_name)try:project.archive()exceptExceptionase:print(e)

what's wrong with it?

You must be logged in to vote

Replies: 1 comment 2 replies

Comment options

You were almost there. The error message points you to the FAQ, and the entry you're looking for is this:
https://python-gitlab.readthedocs.io/en/v3.14.0/faq.html#i-cannot-edit-the-merge-request-issue-i-ve-just-retrieved

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:

importosimportgitlabGIT_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 archivegroup_name='my_group_name'group=client.groups.get(group_name)# Archive all projects in the groupforgroup_projectingroup.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()exceptExceptionase:print(e)
You must be logged in to vote
2 replies
@ayunwSky
Comment options

I didn't understand just now, but after your help, I understand. Thank you

@burn4science
Comment options

Ahh, thanks a lot! I also got it running now! 👍🏼

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
3 participants
@ayunwSky@nejch@burn4science

[8]ページ先頭

©2009-2025 Movatter.jp