为圈子CI配置yaml文件,包括Angular项目的环境变量

Att*_*s29 5 circleci angular circleci-2.0

我有一个我正在尝试构建的项目,但我的.api-keys文档正在被调整.

所以,我将我的密钥作为环境变量添加到圆形CI上的项目中.

我的问题是我不太确定在哪里/如何让我的yaml配置脚本知道它们是什么:

旧配置脚本:

version: 2.1
orbs:
  cypress: cypress-io/cypress@1.0.1
workflows:
  build:
    jobs:
      - cypress/install:
          build: 'npm run build'
      - cypress/run:
          requires:
            - cypress/install
          start: 'npm start'
Run Code Online (Sandbox Code Playgroud)

线路我想添加(我想?):

environment: 
    masterFirebaseConfig: $masterFirebaseConfig
Run Code Online (Sandbox Code Playgroud)

这是正确的做法吗?这条线应该在上面的yaml中去哪儿?

非常感谢任何提示!

2018年12月29日更新:

我将我的api-keys.ts文件更新为:

export var masterFirebaseConfig = {apiKey: $fireBaseApiKey, authDomain: 'dataJitsu.firebaseapp.com',databaseURL: 'https://datajitsu.firebaseio.com',storageBucket: '',messagingSenderId: '495992924984'};
export var masterStripeConfig = {publicApiTestKey: $masterStripePublicApiKey,secretApiTestKey: $masterStripeSecretApiKey,publicApiKey: '',secretApiKey: ''};
Run Code Online (Sandbox Code Playgroud)

其中$ fireBaseApiKey,$ masterStripePublicApiKey和$ masterStripeSecretApiKey是我添加到项目中的环境变量.

这似乎也不起作用:

src/app/api-keys.ts(1,44)中的错误:错误TS2304:找不到名称'$ fireBaseApiKey'.src/app/api-keys.ts(2,52):错误TS2304:找不到名称'$ masterStripePublicApiKey'.src/app/api-keys.ts(2,96):错误TS2304:找不到名称'$ masterStripeSecretApiKey'.

Dip*_*iya 2

我在 VSTS 上为我的 Angular 项目实现了这种 CI-CD,并使用以下方式部署它。

这是build.yaml文件的配置

resources:
- repo: self
queue:
  name: Hosted VS2017
  condition: succeeded()
  demands: npm

steps:
- task: Npm@1
  displayName: npm install
  inputs:
    verbose: false

- task: Npm@1
  displayName: npm custom
  inputs:
    command: custom
    verbose: false
    customCommand: 'run build'

- task: ArchiveFiles@2
  displayName: Archive dist
  inputs:
    rootFolderOrFile: dist
    includeRootFolder: false

- task: PublishBuildArtifacts@1
  displayName: Publish Artifact: drop
  inputs:
    PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
Run Code Online (Sandbox Code Playgroud)

我具体创建了部署文件环境如下。这是一个 QA 实例。

apiVersion: v1
kind: Service
metadata:
  name: portal
  labels:
    app: portal
spec:
  loadBalancerIP: 104.210.66.49
  type: LoadBalancer
  ports:
  - port: 80
    name: http
  selector:
    app: portal
---
apiVersion: apps/v1 
kind: Deployment
metadata:
  name: portal
spec:
  selector:
    matchLabels:
      app: portal
  replicas: 1 
  template: 
    metadata:
      labels:
        app: portal
    spec:
      containers:
      - name: portal
        image: yourdomain.azurecr.io/portal
        ports:
        - containerPort: 80
        env:
        - name: IdentityServerAuthentication__Authority
          value: http://id.qa.yourdomain.com  # Identity URL
        - name: env
          value: qa
      imagePullSecrets:
        - name:  projectqaregistry  # Registry file name
---
Run Code Online (Sandbox Code Playgroud)

要设置 Circle CI 的构建,您可以从这里获取参考