日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

git前端工程实现ci_gitlab中vue前端项目CI/CD部署笔记

發布時間:2024/3/24 vue 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 git前端工程实现ci_gitlab中vue前端项目CI/CD部署笔记 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

持續集成

Gitlab的持續集成

我們可以將整個運行機制,看作一個賞金獵人接任務,執行任務,并完成任務的過程。

GitLab-CI

簡單來說,這就是一個任務發布平臺。運行在gitlab服務器,監聽代碼狀態變化,并發布對應的任務。

GitLab-Runner

而每個runner就是一位賞金獵人,是任務的執行者。

.gitlab-ci.yml

任務的發布者,規定什么時候觸發任務,任務的具體內容。

配置流程

經過前面的解釋,整個思路就很清晰了。我們需要做的有三件事。編寫.gitlab-ci.yml文件,設置對應的任務

部署Runner,激活賞金獵人

配置ci,邀請賞金獵人加入系統

部署Runner

這一步需要一個服務器,能run起來賞金獵人。

安裝

請務必安裝最新版,不然會出現很多未知的問題下載二進制文件# Linux x86-64

sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

# Linux x86

sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386

# Linux arm

sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm

# Linux arm64

sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm64授予執行權限sudo chmod +x /usr/local/bin/gitlab-runnerCreate a GitLab CI user:sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bashInstall and run as service:sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner

sudo gitlab-runner start

加入任務系統

注冊sudo gitlab-runner register

然后就是一些簡單的配置,配置完成后就將該Runner注冊到任務發布平臺了,然后就可以接任務了。詳細見參考文獻【1】

編寫.gitlab-ci.yml任務

本機部署版本

.gitlab-ci.ymlstages:

- deploy

cache:

paths:

- node_modules/

- public/

deployJob:

stage: deploy

script:

- npm install

- npm run build

- rm -rf /home/data/three_miju_shopper_manager_system_front/*

- cp -rf ./dist/* /home/data/three_miju_shopper_manager_system_front/

- sh ./bot.sh ${CI_COMMIT_REF_SLUG} ${CI_COMMIT_SHA:0:8} ${CI_COMMIT_MESSAGE}

tags:

- shared_test_machine_runner

only:

- dev

這個版本具有企業微信群機器人推送功能,需要配置./bot.sh#!/usr/bin/env bash

curl '群機器人地址' \

-H 'Content-Type: application/json' \

-d '

{

"msgtype": "markdown",

"markdown": {

"content": "商戶端代碼已更新,分支:'$1' 提交:'$2'

更新:'$3'

已發布,[點擊測試](http://test.shop.gileey.cn)"

}

}'

遠程推送版本stages:

- deploy

cache:

paths:

- node_modules/

- public/

deployJob:

stage: deploy

script:

- mkdir -p ~/.ssh

- echo "$SSH_PRIVATE_KEY" >> ~/.ssh/id_dsa

- chmod 600 ~/.ssh/id_dsa

- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config

- rsync -avzu --progress ./dist/* root@thinkmoon.cn:/www/wwwroot/3ju.psyannabel.cn/

tags:

- shared_test_machine_runner

only:

- dev

該版本在gitlab-runner機器上執行編譯等工作,編譯完成后使用rsync同步到云服務器,需要配置私鑰變量$SSH_PRIVATE_KEY

遇到的問題

導入自定義組件時一直報錯:This dependency was not found:

出現背景:由于以前命名組件是"clickImg",后改成"ClickImg",由于linux的區分大小寫,所以會一直沒找到。

解決方案:換個名字???

參考文獻

總結

以上是生活随笔為你收集整理的git前端工程实现ci_gitlab中vue前端项目CI/CD部署笔记的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。