簡體   English   中英

使用 Gitlab CI 部署 Vue.js 構建

[英]Deploy Vue.js build with Gitlab CI

這是我的 gitlab 管道。 Vue.js 工件是在運行器上構建的。 如何部署到我的測試服務器? 僅供參考: Fab pull對 repo 執行git pull

deploy_staging:
  image: python:3.6
  stage: deploy
  only:
    - master
  before_script:
    - curl -sL https://deb.nodesource.com/setup_13.x | bash -
    - apt-get update -y
    - apt-get install -y curl git gnupg nodejs
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - |
      cat >~/.ssh/config <<EOF
      Host testserver
          ForwardAgent yes
          HostName dev.testserver.ts
          User testuser
      EOF
    - cat ~/.ssh/config
  script:
    - pip install -r requirements.txt
    - npm install
    - npm run production
    - fab pull

由於您想將文件從 GitLab 運行器復制到您的服務器中,因此可以使用scp命令。 例如:

⋮
 script:
    - pip install -r requirements.txt
    - npm install
    - npm run production
    - scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no /PATH/TO/BUILD_ARTIFACTS testserver:~/PATH/TO/DESTINATION
    - fab pull

UserKnownHostsFileStrictHostKeyChecking是防止錯誤Host key verification failed的 SSH 選項。 因此,在您的情況下,它們應該與scp命令一起使用。
此外,工件文件的目標路徑必須從testuser的主目錄(波浪字符~ )開始。 否則你可能會遇到Permission denied錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM