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编写教程

相关推荐
dong_junshuai6 小时前
每天一个开源项目#68 Needle:14MB 工具调用小模型装进口袋设备
程序员·开源·github
Python私教6 小时前
AI 并行编码的 Worktree 生命周期:创建、隔离与安全回收
人工智能·git
互联网中的一颗神经元7 小时前
16 — 改写历史 rebase:搬家到新楼层,不是合并
git
向上的车轮10 小时前
GitHub Actions 自动化运维实战:Rust 全栈项目 CI/CD 至华为云
运维·自动化·github
互联网中的一颗神经元11 小时前
19 — 贮藏与清理:stash 是抽屉,gc 是打包箱
git
MicrosoftReactor12 小时前
技术速递|GitHub Copilot App 中的堆叠会话与拉取请求
ai·github·copilot·agent
dong_junshuai13 小时前
每天一个开源项目#67 Orca:4.3万星的并行 AI 编程控制台
程序员·开源·github
用户3301448676313 小时前
20 — 远程进阶:强制推送的保险绳——force-with-lease
git
Cooper2513 小时前
别急着改 Git 历史:rebase、cherry-pick、bisect 与 reflog 的安全操作顺序
git