我正在尝试在VueJS应用程序的CI作业的build
阶段使用环境变量。我使用的是GitLab CI,其中一个可用的环境变量是CI_COMMIT_SHORT_SHA
,
build:
image: node:latest
stage: build
variables:
CI_COMMIT_SHORT_SHA: "$CI_COMMIT_SHORT_SHA"
artifacts:
paths:
- dist/
script:
- npm install --progress=false
- npm run build
- echo "Build Complete"
下面是我在Vue中使用这个变量的方法:
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>This is a static site that is served with a CloudFront distribution in front of an S3 bucket.</p>
<p>The site is updated through a GitLab CI/CD pipeline.</p>
<p>Commit ref: {{ commit }}</p>
<p>Using cache invalidation</p>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
},
data(){
return {
commit: process.env.CI_COMMIT_SHORT_SHA
}
}
}
</script>
我看不到这个变量的作用。为了访问环境变量并将其显示在我的组件中,我还需要做些什么吗?
https://stackoverflow.com/questions/54792619
复制相似问题