I was looking for something similar, getting all the projects from several groups.
There are two ways to do this, which I can see, depending on how much information you know about the group and how dynamic you need it.
Option 1
If you know the identifiers of the groups that you need, you can get the group by identifier and provide you with projects
projects = Gitlab.group(group_id).projects
Option 2
If you do not know the group identifiers or should be able to transfer group names more dynamically, you will need to make an additional call to get all the groups, go through them and get individual groups. It may not be better than your initial idea of ββthe cycle for all projects, it depends on how many groups / projects you have
groups = [] Gitlab.groups.each do |group| if ['your_group_name', 'another_group_name'].include? group.name groups << Gitlab.group(group.id) end end projects = [] groups.each do |group| projects << group.projects end
I am by no means a specialist in Ruby programming, so there is no doubt that they are much better suited for this or improve the code, but it worked for my needs, as it was needed only from time to time, so speed was not a problem for me
Dave Kirk Jul 31 '15 at 9:33 2015-07-31 09:33
source share