在大厅管道中运行npm

时间:2017-02-25 14:29:09

标签: npm continuous-integration concourse

如何添加作为我的管道的一部分,它需要获取git存储库,运行npm install和npm build,然后推送到云代工厂?

到目前为止,我能够抓住存储库并推送到云代工厂。但不完全确定如何制作它以便构建npm任务。我正在使用BOSH导演来处理所有的大厅内容。

任何方向或想法都将非常感激。我在这里遵循本教程并基于此管道: (我将在何处以及如何添加构建npm任务?)

---
resources:
- name: resource-web-app
  type: git
  source:
    uri: https://github.com/cloudfoundry-community/simple-go-web-app.git

- name: resource-deploy-web-app
  type: cf
  source:
    api: {{cf-api}}
    username: {{cf-username}}
    password: {{cf-password}}
    organization: {{cf-organization}}
    space: {{cf-space}}
    skip_cert_check: true

jobs:
- name: job-deploy-app
  serial: true
  plan:
  - {get: resource-web-app, trigger: true}
  - put: resource-deploy-web-app
    params:
      manifest: resource-web-app/manifest.yml
      path: resource-web-app

https://github.com/starkandwayne/concourse-tutorial/tree/master/15_deploy_cloudfoundry_app

1 个答案:

答案 0 :(得分:2)

在推送到云代工厂之前,您需要编写一个task来运行运行npm installnpm build的脚本。

同样重要的是要注意,在下面的脚本中,concourse将在目录resource-deploy-web-app中查找要推送到cf的位,因此请确保在脚本中放置要推送的所有内容。

所以你的新工作配置看起来像是:

jobs:
- name: job-deploy-app
  serial: true
  plan:
  - {get: resource-web-app, trigger: true}
  - task: build-npm
    config:
      platform: linux
      image_resource:
        type: docker-image
        source:
          repository: node

      inputs:
        - name: resource-web-app

      run:
        path: resource-web-app/scripts/script-that-does-npm-stuff.sh

      outputs:
        - name: resource-deploy-web-app

 - put: resource-deploy-web-app
   params:
      manifest: resource-web-app/manifest.yml
      path: resource-web-app