BigW Consortium Gitlab

info.rake 3.58 KB
Newer Older
1
namespace :gitlab do
2
  namespace :env do
3
    desc "GitLab | Show information about GitLab and its environment"
4
    task info: :environment  do
5
      # check if there is an RVM environment
6
      rvm_version = run_and_match(%w(rvm --version), /[\d\.]+/).try(:to_s)
7
      # check Ruby version
8
      ruby_version = run_and_match(%w(ruby --version), /[\d\.p]+/).try(:to_s)
9
      # check Gem version
10
      gem_version = run_command(%w(gem --version))
11
      # check Bundler version
12
      bunder_version = run_and_match(%w(bundle --version), /[\d\.]+/).try(:to_s)
13
      # check Rake version
14
      rake_version = run_and_match(%w(rake --version), /[\d\.]+/).try(:to_s)
15
      # check redis version
16
      redis_version = run_and_match(%w(redis-cli --version), /redis-cli (\d+\.\d+\.\d+)/).to_a
17 18
      # check Git version
      git_version = run_and_match([Gitlab.config.git.bin_path, '--version'], /git version ([\d\.]+)/).to_a
19 20
      # check Go version
      go_version = run_and_match(%w(go version), /go version (.+)/).to_a
21 22

      puts ""
23 24
      puts "System information".color(:yellow)
      puts "System:\t\t#{os_name || "unknown".color(:red)}"
25
      puts "Current User:\t#{run_command(%w(whoami))}"
26
      puts "Using RVM:\t#{rvm_version.present? ? "yes".color(:green) : "no"}"
27
      puts "RVM Version:\t#{rvm_version}" if rvm_version.present?
28 29 30 31
      puts "Ruby Version:\t#{ruby_version || "unknown".color(:red)}"
      puts "Gem Version:\t#{gem_version || "unknown".color(:red)}"
      puts "Bundler Version:#{bunder_version || "unknown".color(:red)}"
      puts "Rake Version:\t#{rake_version || "unknown".color(:red)}"
32
      puts "Redis Version:\t#{redis_version[1] || "unknown".color(:red)}"
33
      puts "Git Version:\t#{git_version[1] || "unknown".color(:red)}"
34
      puts "Sidekiq Version:#{Sidekiq::VERSION}"
35
      puts "Go Version:\t#{go_version[1] || "unknown".color(:red)}"
36 37 38 39

      # check database adapter
      database_adapter = ActiveRecord::Base.connection.adapter_name.downcase

40
      project = Group.new(path: "some-group").projects.build(path: "some-project")
41 42 43 44
      # construct clone URLs
      http_clone_url = project.http_url_to_repo
      ssh_clone_url  = project.ssh_url_to_repo

45
      omniauth_providers = Gitlab.config.omniauth.providers
46 47
      omniauth_providers.map! { |provider| provider['name'] }

48
      puts ""
49
      puts "GitLab information".color(:yellow)
50 51
      puts "Version:\t#{Gitlab::VERSION}"
      puts "Revision:\t#{Gitlab::REVISION}"
52 53
      puts "Directory:\t#{Rails.root}"
      puts "DB Adapter:\t#{database_adapter}"
54
      puts "URL:\t\t#{Gitlab.config.gitlab.url}"
55 56
      puts "HTTP Clone URL:\t#{http_clone_url}"
      puts "SSH Clone URL:\t#{ssh_clone_url}"
57 58 59
      puts "Using LDAP:\t#{Gitlab.config.ldap.enabled ? "yes".color(:green) : "no"}"
      puts "Using Omniauth:\t#{Gitlab.config.omniauth.enabled ? "yes".color(:green) : "no"}"
      puts "Omniauth Providers: #{omniauth_providers.join(', ')}" if Gitlab.config.omniauth.enabled
60 61

      # check Gitolite version
62
      gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.hooks_path}/../VERSION"
63 64
      if File.readable?(gitlab_shell_version_file)
        gitlab_shell_version = File.read(gitlab_shell_version_file)
65 66 67
      end

      puts ""
68 69
      puts "GitLab Shell".color(:yellow)
      puts "Version:\t#{gitlab_shell_version || "unknown".color(:red)}"
70
      puts "Repository storage paths:"
71 72
      Gitlab.config.repositories.storages.each do |name, repository_storage|
        puts "- #{name}: \t#{repository_storage['path']}"
73
      end
74
      puts "Hooks:\t\t#{Gitlab.config.gitlab_shell.hooks_path}"
75
      puts "Git:\t\t#{Gitlab.config.git.bin_path}"
76 77 78
    end
  end
end