Ubuntu22.04阿里云服务器 Gitlab搭建CICD

gitlab搭建cicd流水线教程

1、阿里云申请免费云盘

申请免费云盘用于创建gitlab 申请方法百度

2、安装gitlab-ce

更新系统:

bash 复制代码
sudo apt update
sudo apt upgrade -y

安装必要的依赖:

bash 复制代码
sudo apt install -y curl openssh-server ca-certificates postfix

postfix 是用来发送邮件的 MTA(邮件传输代理),在安装过程中,Postfix 会询问你配置类型。选择"Internet Site"然后按回车键继续,接着输入你的主机名或域名。

关闭防火墙

bash 复制代码
sudo ufw disable
sudo ufw status  查看防火墙状态

安装 GitLab CE

添加 GitLab 包源:

首先需要添加 GitLab 的官方包源到你的系统中。你可以通过以下命令来完成:

bash 复制代码
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash

安装 GitLab CE:

添加了源之后,就可以安装 GitLab CE 了:

bash 复制代码
sudo apt-get install gitlab-ce

修改对外端口管理

bash 复制代码
cd /etc/gitlab/
vi gitlab.rb

修改字段:
external_url 'http://8.154.25.238:80'
nginx['listen_port'] = 80
可以直接在rb文件下添加 

初始化gitlab

bash 复制代码
gitlab-ctl reconfigure
gitlab-ctl restart

网页打开:

bash 复制代码
http://8.154.25.238:80

登录账号 root

密码:

3、安装注册gitlab-runner

复制代码
# For Debian/Ubuntu/Mint
 curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash

 # For RHEL/CentOS/Fedora
 curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.rpm.sh | sudo bash



# MacOS
sudo brew install gitlab-ci-multi-runner
 # For Debian/Ubuntu/Mint

 sudo apt-get install gitlab-ci-multi-runner

 # For RHEL/CentOS/Fedora
 sudo yum install gitlab-ci-multi-runner

4、代码测试

4.1、创建项目 例如cicd_test

4.2、添加ssh秘钥拉取项目代码

4.3、创建**.gitlab-ci.yml**文件

文件内容:

XML 复制代码
stages: # 分段
  - deploy

deploy-job:
  stage: deploy
  script:
    - echo "abc"
    - echo "123"

注意:文件名一点不能差。。。坑

4.4、push代码后runner开始作业

至此结束。。。。。后面出个gitlab-ci编写教程

相关推荐
CoderJia程序员甲2 小时前
GitHub 热榜项目 - 日榜(2026-01-24)
git·ai·开源·llm·github
莫问前路漫漫2 小时前
Electerm 连接远程服务器完整指南
运维·服务器·git
鸣弦artha3 小时前
TabBar标签页组件详解
linux·git·ubuntu
TTGGGFF6 小时前
告别繁琐命令行:自研多线程 SSH 极速文件传输助手(附 GitHub 源码)
运维·ssh·github
小林up6 小时前
Ubuntu访问不了Git解决办法
linux·git·ubuntu
月初,19 小时前
Git 常用操作大全(超详细教程)一文教会你完全使用Git
大数据·git·elasticsearch
普通网友19 小时前
远程配置 VsCode:Github Copilot 安装成功却无法使用?细节避坑
vscode·github·copilot
李少兄21 小时前
Git 忽略文件机制:.gitignore 与 .git/info/exclude
java·git·elasticsearch
极智-99621 小时前
GitHub 热榜项目-日榜精选(2026-01-24)| AI智能体工具、Python生态等 | remotion、VibeVoice、goose等
人工智能·python·github·ai智能体·大模型部署·语音ai
github.com/starRTC1 天前
Claude Code中英文系列教程17:将Claude Code集成在GitLab工作流里面
git·gitlab·github