GitLab安装
- 安装依赖
apt-get install -y curl openssh-server ca-certificates tzdata perl- 安装
# 通过源安装curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bashapt install gitlab-ce# 手动下载安装wget https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/jammy/gitlab-ce_16.0.9-ce.0_amd64.debdpkg -i gitlab-ce_16.0.9-ce.0_amd64.deb# 安装 gitlab runnerwget https://s3.dualstack.us-east-1.amazonaws.com/gitlab-runner-downloads/latest/binaries/gitlab-runner-linux-amd64dpkg -i gitlab-runner-linux-amd64.debexternal_url 'http://example.com:8091' #配置外部链接
puma['listen'] = '0.0.0.0' #后端服务,直接访问没有静态文件puma['port'] = 8080
gitlab_workhorse['listen_network'] = "tcp" #直接访问,不经过代理gitlab_workhorse['listen_addr'] = "127.0.0.1:8091"
nginx['listen_port'] = 8888 #配置内置nginx启动端口
# 以下配置自己的mysql数据库而不是用内置的数据库postgresql['enable'] = false #关闭内置postgresql数据库gitlab_rails['db_adapter'] = "postgresql"gitlab_rails['db_encoding'] = "utf8"gitlab_rails['db_database'] = "gitlab"gitlab_rails['db_username'] = "root"gitlab_rails['db_password'] = "example"gitlab_rails['db_host'] = "localhost"gitlab_rails['db_port'] = 5433
# 以下配置自定的redis而不是用内置的redisredis['enable'] = falsegitlab_rails['redis_host'] = "127.0.0.1"gitlab_rails['redis_port'] = 6380gitlab_rails['redis_password'] = "example"
# 以下配置自定的nginx而不是用内置的nginxnginx['enable'] = false
# 配置ssh默认用户user['username'] = "gitlab"user['group'] = "gitlab"gitlab_rails['gitlab_ssh_host'] = 'gitlab.wsl.sxyxy.top'gitlab_rails['gitlab_ssh_user'] = 'gitlab'gitlab-ctl reconfigure #基于配置文件重新配置 APPgitlab-ctl start appName #缺省代表所有的服务gitlab-ctl status appNamegitlab-ctl restart appNamegitlab-ctl service-list #查看所有的服务gitlab-rake "gitlab:password:reset" #修改密码# 管理systemctl disable gitlab-runsvdir #gitlabsystemctl start gitlab-runsvdir #gitlabsystemctl stop gitlab-runsvdir #gitlabsystemctl restart gitlab-runsvdir #gitlabsystemctl enable gitlab-runsvdir #gitlabsystemctl disable gitlab-runner #runnersystemctl start gitlab-runner #runnersystemctl stop gitlab-runner #runnersystemctl restart gitlab-runner #runnersystemctl enable gitlab-runner #runner
gitlab-ctl cleanse #清空重来rm -rf /opt/gitlanb #清除、然后重新安装dkpg- i /opt/software/gitlab-ce_16.0.9-ce.0_amd64.deb5.1. 用户组
Section titled “5.1. 用户组”…
5.2. 用户
Section titled “5.2. 用户”…
5.3. 仓库
Section titled “5.3. 仓库”…
5.4. Runner
Section titled “5.4. Runner”- 注册
gitlab-runner register --url https://example.com --token 123- 配置 executor
- Shell:在运行 GitLab Runner 的机器上直接使用 shell 命令运行作业。
- Docker:在 Docker 容器中运行作业,提供了一种隔离的环境。
- Docker Machine:在动态创建的 Docker 容器中运行作业,可以根据需求动态扩展。
- Kubernetes:在 Kubernetes 集群中运行作业,适用于容器化应用的部署。
- VirtualBox:在 VirtualBox 虚拟机中运行作业,适合需要虚拟化环境的情况。
- Custom:允许用户定义自定义的执行器。
- 仓库配置 .gitlab-cli.yml 文件
stages: # List of stages for jobs, and their order of execution - build - test - deploy
build-job: # This job runs in the build stage, which runs first. stage: build tags: - test_new script: - echo "Compiling the code..." - echo "Compile complete."
unit-test-job: # This job runs in the test stage. stage: test # It only starts when the job in the build stage completes successfully. tags: - test_new script: - echo "Running unit tests... This will take about 60 seconds." - sleep 60 - echo "Code coverage is 90%"
lint-test-job: # This job also runs in the test stage. stage: test # It can run at the same time as unit-test-job (in parallel). tags: - test_new script: - echo "Linting code... This will take about 10 seconds." - sleep 10 - echo "No lint issues found."
deploy-job: # This job runs in the deploy stage. stage: deploy # It only runs when *both* jobs in the test stage complete successfully. tags: - test_new environment: production script: - echo "Deploying application..." - echo "Application successfully deployed."- 命令使用
gitlab-runner register # 注册gitlab-runner run #测试使用gitlab-runner startgitlab-runner statusgitlab-runner stopgitlab-runner restartgitlab-runner unregister --name <RUNNER_NAME> #取消注册6. 拓展信息
Section titled “6. 拓展信息”6.1. CE 与 EE 的区别
Section titled “6.1. CE 与 EE 的区别”CE 是社区版本,EE 是商业版本
6.2. GitLab 12.1 版本之后仅支持 postgresql 数据库
Section titled “6.2. GitLab 12.1 版本之后仅支持 postgresql 数据库”6.3. Wait for Logrotate Service Socket Gitlab 卡死
Section titled “6.3. Wait for Logrotate Service Socket Gitlab 卡死”systemctl restart gitlab-runsvdirgitlab-ctl reconfigure6.4. 项目页面 500
Section titled “6.4. 项目页面 500”gitlab-rake cache:clear #清理缓存6.5. 当前依赖服务
Section titled “6.5. 当前依赖服务”- postgresql
- redis
- nginx(https 需要)
- runner(CI CD 需要)