Linux-Manual

Gitlab 安装和配置

Docker Compose 安装方式

gitlab:
  image: sameersbn/gitlab:10.4.2-1
  ports:
    - "10022:22"
    - "10080:80"
  links:
    - gitlab-redis:redisio
    - gitlab-postgresql:postgresql
  environment:
    - GITLAB_PORT=80
    - GITLAB_SSH_PORT=22
    - GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string
    - GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string
    - GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string
  volumes:
    - /data/docker/gitlab/gitlab:/home/git/data
  restart: always
gitlab-redis:
  image: sameersbn/redis
  volumes:
    - /data/docker/gitlab/redis:/var/lib/redis
  restart: always
gitlab-postgresql:
  image: sameersbn/postgresql:9.6-2
  environment:
    - DB_NAME=gitlabhq_production
    - DB_USER=gitlab
    - DB_PASS=password
    - DB_EXTENSION=pg_trgm
  volumes:
    - /data/docker/gitlab/postgresql:/var/lib/postgresql
  restart: always

Gitlab 高可用方案(High Availability)

原始安装方式(推荐)

sudo yum install -y curl policycoreutils-python openssh-server

sudo systemctl enable sshd
sudo systemctl start sshd

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
sudo EXTERNAL_URL="http://192.168.1.123:8181" yum install -y gitlab-ce

配置

配置 Jenkins 拉取代码权限

权限

用户组的权限

行为 Guest Reporter Developer Master Owner
浏览组
编辑组        
创建项目      
管理组成员        
移除组        

项目组的权限

行为 Guest Reporter Developer Master Owner
创建issue
留言评论
更新代码  
下载工程  
创建代码片段  
创建合并请求    
创建新分支    
提交代码到非保护分支    
强制提交到非保护分支    
移除非保护分支    
添加tag    
创建wiki    
管理issue处理者    
管理labels    
创建里程碑      
添加项目成员      
提交保护分支      
使能分支保护      
修改/移除tag      
编辑工程      
添加deploy keys      
配置hooks      
切换visibility level        
切换工程namespace        
移除工程        
强制提交保护分支        
移除保护分支        

批量从一个项目中的成员转移到另外一个项目

限定哪些分支可以提交、可以 merge

Gitlab 的其他功能使用

创建用户

创建群组

创建项目

增加 SSH keys

使用 Gitlab 的一个开发流程 - Git flow

接入第三方登录

gitlab_rails['omniauth_enabled'] = true
gitlab_rails['omniauth_allow_single_sign_on'] = ['google_oauth2', 'facebook', 'twitter', 'oauth2_generic']
gitlab_rails['omniauth_block_auto_created_users'] = false
gitlab_rails['omniauth_sync_profile_attributes'] = ['email','username']
gitlab_rails['omniauth_external_providers'] = ['google_oauth2', 'facebook', 'twitter', 'oauth2_generic']
gitlab_rails['omniauth_providers'] = [
    {
        "name"=> "google_oauth2",
        "label"=> "Google",
        "app_id"=> "123456",
        "app_secret"=> "123456",
        "args"=> {
            "access_type"=> 'offline',
            "approval_prompt"=> '123456'
        }
    },
    {
        "name"=> "facebook",
        "label"=> "facebook",
        "app_id"=> "123456",
        "app_secret"=> "123456"
    },
    {
        "name"=> "twitter",
        "label"=> "twitter",
        "app_id"=> "123456",
        "app_secret"=> "123456"
    },
    {
        "name" => "oauth2_generic",
        "app_id" => "123456",
        "app_secret" => "123456",
        "args" => {
          client_options: {
            "site" => "http://sso.cdk8s.com:9090/sso",
            "user_info_url" => "/oauth/userinfo"
          },
          user_response_structure: {
            root_path: ["user_attribute"],
            attributes: { 
              "nickname": "username" 
            }
          }
        }
    }
]

资料