BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
168e0341
Commit
168e0341
authored
Feb 12, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5520 from gabetax/rake_group_bulk_add_permissions
add rake gitlab:import: all_users_to_all_groups and user_to_groups
parents
5b0aa252
17105038
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
0 deletions
+40
-0
user_management.md
doc/raketasks/user_management.md
+16
-0
bulk_add_permission.rake
lib/tasks/gitlab/bulk_add_permission.rake
+24
-0
No files found.
doc/raketasks/user_management.md
View file @
168e0341
...
...
@@ -14,3 +14,19 @@ Notes:
```
bash
bundle
exec
rake gitlab:import:all_users_to_all_projects
```
### Add user as a developer to all projects
```
bundle exec rake gitlab:import:user_to_groups[username@domain.tld]
```
### Add all users to all groups
Notes:
*
admin users are added as owners so they can add additional users to the group
```
bundle exec rake gitlab:import:all_users_to_all_groups
```
lib/tasks/gitlab/bulk_add_permission.rake
View file @
168e0341
...
...
@@ -20,5 +20,29 @@ namespace :gitlab do
puts
"Importing
#{
user
.
email
}
users into
#{
project_ids
.
size
}
projects"
UsersProject
.
add_users_into_projects
(
project_ids
,
Array
.
wrap
(
user
.
id
),
UsersProject
::
DEVELOPER
)
end
desc
"GITLAB | Add all users to all groups (admin users are added as owners)"
task
all_users_to_all_groups: :environment
do
|
t
,
args
|
user_ids
=
User
.
where
(
admin:
false
).
pluck
(
:id
)
admin_ids
=
User
.
where
(
admin:
true
).
pluck
(
:id
)
groups
=
Group
.
all
puts
"Importing
#{
user_ids
.
size
}
users into
#{
groups
.
size
}
groups"
puts
"Importing
#{
admin_ids
.
size
}
admins into
#{
groups
.
size
}
groups"
groups
.
each
do
|
group
|
group
.
add_users
(
user_ids
,
UsersGroup
::
DEVELOPER
)
group
.
add_users
(
admin_ids
,
UsersGroup
::
OWNER
)
end
end
desc
"GITLAB | Add a specific user to all groups (as a developer)"
task
:user_to_groups
,
[
:email
]
=>
:environment
do
|
t
,
args
|
user
=
User
.
find_by_email
args
.
email
groups
=
Group
.
all
puts
"Importing
#{
user
.
email
}
users into
#{
groups
.
size
}
groups"
groups
.
each
do
|
group
|
group
.
add_users
(
Array
.
wrap
(
user
.
id
),
UsersGroup
::
DEVELOPER
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment