“集成 Ubuntu GitLab”通常有以下几种常见含义,我按最常见的几种场景分别说明,你可以对照自己的需求:
sudo apt update
sudo apt install -y curl openssh-server ca-certificates postfix
curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash
sudo EXTERNAL_URL="http://gitlab.example.com" apt install gitlab-ce
如果是本机测试,可写
http://你的UbuntuIP
http://服务器IPsudo apt install git
git config --global user.name "你的名字"
git config --global user.email "you@example.com"
ssh-keygen -t ed25519 -C "you@example.com"
cat ~/.ssh/id_ed25519.pub
把公钥添加到 GitLab → User Settings → SSH Keys
git clone git@gitlab.example.com:group/project.git
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
sudo apt install gitlab-runner
sudo gitlab-runner register
按提示填写:
shell / docker)在项目中添加 .gitlab-ci.yml 即可自动构建、测试、部署。
常见方式:
/hook 服务)如果你是想**“代码推送到 GitLab 后自动部署到 Ubuntu 服务器”**,我可以给你完整示例。
我可以直接给你一份适合你场景的详细步骤。