【发布时间】:2020-02-27 05:55:47
【问题描述】:
我想将 Git 哈希打印到我的 Vue.js 应用的页脚中。我已按照此问题中的说明进行操作:
How to use environment variables at build time in a VueJS project
但就是不能让它工作。未为应用设置 process.env.VUE_APP_GIT_COMMIT 变量。 .env 文件中设置的变量可以正常工作。
.gitlab.ci.yml:
build-frontend:
image: node:10.16.3-stretch
stage: build
before_script:
- cd frontend
variables:
VUE_APP_GIT_COMMIT: "$CI_COMMIT_SHORT_SHA"
script:
- npm install -g @vue/cli@3.11.0
- npm install
- npm run staging
artifacts:
paths:
- frontend/dist/
expire_in: 1 hour
deploy-staging-frontend:
image: python:3.7.4
stage: deploy
script:
- pip install awscli
- aws s3 sync --delete frontend/dist s3://bucket
【问题讨论】:
-
试写:
before_script: - echo "VUE_APP_GIT_COMMIT=$CI_COMMIT_SHORT_SHA" >> .env