Bulk update all users personal project limits

People often ask why after changing default projects limit users can still create more projects.

This setting is for newly created users. You can check that old users limits did not change (check Admin area > Overview > Users > Edit user > Projects limit)

This is an example gitlab-rails console snippet that will update all non-admin users personal project limit to 5.

If you want to update all, including admins, just remove if not u.admin? and first end (the one right after u.save)

User.all.each do |u|
  if not u.admin?
    puts u.username
    puts u.projects_limit
    u.projects_limit=5
    u.save
  end
  puts u.username
  puts u.projects_limit
end

Enable soft delete on all groups via gitlab-rails console

The gitlab-rails console snippet to enable soft delete on all groups:

People often ask why after changing default projects limit users can still create more projects.

This setting is for newly created users. You can check that old users limits did not change (check Admin area > Overview > Users > Edit user > Projects limit)

This is an example gitlab-rails console snippet that will update all non-admin users personal project limit to 5.

If you want to update all, including admins, just remove if not u.admin? and first end (the one right after u.save)

User.all.each do |u|
  if not u.admin?
    puts u.username
    puts u.projects_limit
    u.projects_limit=5
    u.save
  end
  puts u.username
  puts u.projects_limit
end

Remove all job logs and artifacts in your GitLab instance

Use with caution. This is a gitlab-rails console script that removes all job logs and artifacts. Good for small test instances when you need to free up some space.

admin_user = User.find_by(username: 'root')
 Ci::Build.find_each do |build|
   print "Ci::Build ID #{build.id}… "
   if build.erasable?
     build.erase(erased_by: admin_user)
     puts "Erased"
   else
     puts "Skipped (Nothing to erase or not erasable)"
   end
 end
Ruby