入门掌握 CI CD 的用法学习 CI 和 CD 的含义及其实现细节基于 GitLab 展示如何给自己手上的项目添加 CICD 的流程摘要:进入到gitlab控制面板中 gitlab-rails console -e production2.执行命令: user = User.where(id: 1).first,此 user 则表示 root 用户3、修改密码 执行命令:user.passwor
学习本文你需要 注意 的事情
你的项目必须是支持Node版本 16.20.0读者的CentOS安装Node18以上的版本底层库不支持,如果你想安装高版本的Node请先解决CentOS版本低的问题本文采用的是 CentOS Linux操作系统本文的操作系统版本截图在下方#技术分享OK 如果你已经明白了我上面说的注意事项 那我们事不宜迟,直接开始本文的内容吧。
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
nvm install 16.20.0
nvm use nodenvm use node 16.20.0
zlib 开启 gzIp 需要openssl 开启 SSL 需要pcre rewrite模块需要gcc-c++ C/C++ 编译器yum -y install gcc-c++ zlib zlib-devel openssl openssl-devel pcre pcre-devel
wget https://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gzcd ./nginx-1.18.0./configuremakemake install查看安装路径开放 80 端口 如果不想一次性一个一个的放行端口,可以关闭防火墙firewall-cmd --permanent --zone=public --add-port=80/tcp
重载防火墙firewall-cmd --reload
启动nginx
yum -y install https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.3.0-ce.0.el7.x86_64.rpm
vim /etc/gitlab/gitlab.rb
gitlab-ctl reconfigure
开放 1874 端口firewall-cmd --permanent --zone=public --add-port=1874/tcp
1.进入到gitlab控制面板中 gitlab-rails console -e production2.执行命令: user = User.where(id: 1).first,此 user 则表示 root 用户3、修改密码 执行命令:user.password = '12345678'修改密码 再次执行 user.password_confirmation = '12345678' 确认密码4、保存密码 执行命令:user.save!5、退出控制台 执行命令:exithttp://192.168.80.130:1874/users/sign_in 把Ip换成自己的Ip 输入root的用户名和密码尝试进行登录,正常创建项目进行测试
wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64
分配运行权限chmod +x /usr/local/bin/gitlab-runner
创建用户useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash
gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner
运行测试 webpack-vue 项目部署
webpack-vue-cicd
直接回车走过
shell
注册完成后,就可以在 http://192.168.80.130/admin/runners 里面看到创建的 runner。
firewall-cmd --permanent --zone=public --add-port=3001/tcp
server { listen 80 server_name localhostlocation / { root html index index.html index.htm }error_page 500 502 503 504 /50x.html location = /50x.html { root html } }server { listen 3001 server_name localhost location / { root /www/wwwroot/dist index index.html index.htm } error_page 500 502 503 504 /50x.html location = /50x.html { root html } }# 阶段stages: - build - deploy# 缓存 node_modules 减少打包时间,默认会清除 node_modules 和 distcache: paths: - node_modules/# 拉取项目,打包build: stage: build tags: - ceshi before_script: # - export PATH=/usr/local/bin:$PATH- node --version - npm --version - echo "开始构建" script: - cd ${CI_PROJECT_DIR} - npm install - npm run build only: - main artifacts: paths: - dist/# 部署deploy: stage: deploy tags: - ceshi script: - rm -rf /www/wwwroot/dist来源:墨码行者