rake 任务异常跳过
This commit is contained in:
parent
5f56edda15
commit
be1fc144da
|
@ -3,13 +3,13 @@ namespace :gitlab do
|
|||
task :sync_data => :environment do
|
||||
s = Trustie::Gitlab::Sync.new
|
||||
g = Gitlab.client
|
||||
begin
|
||||
projects = Project.where("gpid is not null and status=?", 1)
|
||||
projects.each do |project|
|
||||
# sync members and roles
|
||||
begin
|
||||
if project.members.count != g.team_members(project.gpid).count
|
||||
DataException.create(:message => "project's members is not true", :container_id => project.id, :container_type => "Project")
|
||||
project.members.each do |m|
|
||||
begin
|
||||
gid = m.user.gid
|
||||
if gid.nil?
|
||||
gid = s.sync_user(m.user).id
|
||||
|
@ -19,12 +19,20 @@ namespace :gitlab do
|
|||
g.add_team_member(project.gpid, gid, access_level)
|
||||
# sync members' roles
|
||||
g.edit_team_member(project.gpid, gid, access_level)
|
||||
rescue Exception => e
|
||||
DataException.create(:message => e.message, :container_id => project.id, :container_type => "Project")
|
||||
puts e
|
||||
end
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
puts e
|
||||
end
|
||||
end
|
||||
|
||||
users = User.where("gid is not null and status =?", 1)
|
||||
users.each do |user|
|
||||
begin
|
||||
# sync username
|
||||
g.edit_user(user.gid, :username => user.login) if user.login != g.user(user.gid).try(:username)
|
||||
|
||||
|
@ -34,11 +42,9 @@ namespace :gitlab do
|
|||
# sync password
|
||||
options = {:encrypted_password=> user.hashed_password, :password_salt=> user.salt}
|
||||
g.put("/users/ext/#{user.gid}", :body => options)
|
||||
end
|
||||
rescue Exception => e
|
||||
DataException.create(:message => e.message)
|
||||
puts e
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue