[英]Pass build directory (/dist) from a job to next job in concourse
我知道这样做并不容易,并试图探索许多方法,但要么我无法正确理解它,要么对我不起作用。
我有一个运行 angular build (ng build) 并创建 /dist 文件夹的大厅作业。 这很好用。
jobs:
- name: cache
plan:
- get: source
trigger: true
- get: npm-cache
- name: build
plan:
- get: source
trigger: true
passed: [cache]
- get: npm-cache
passed: [cache]
- task: run build
file: source/ci/build.yml
---
platform: linux
image_resource:
type: docker-image
source: { repository: alexsuch/angular-cli, tag: '7.3' }
inputs:
- name: source
- name: npm-cache
path: /cache
outputs:
- name: artifact
run:
path: source/ci/build.sh
#!/bin/sh
mv cache/node_modules source
cd source
npm rebuild node-saas # temporary fix
npm run build_prod
cp -R dist ../artifact/
我已经提到输出是我存储 dist 内容的工件。 但是当我尝试在下一份工作中使用它时,它不起作用。 因缺少输入错误而失败。
这是应该使用此 dist 文件夹的下一个作业:
jobs:
...
...
- name: list
plan:
- get: npm-cache
passed: [cache, test, build]
trigger: true
- task: list-files
config:
platform: linux
image_resource:
type: registry-image
source: { repository: busybox }
inputs:
- name: artifact
run:
path: ls
args: ['-la', 'artifact/']
任何人都可以帮我解决这个问题。 我如何在上述工作中使用 dist 文件夹。
我不太确定你为什么要为每个任务有不同的计划定义,但这是做你想做的事情的最简单的方法:
jobs:
- name: deploying-my-app
plan:
- get: source
trigger: true
passed: []
- get: npm-cache
passed: []
- task: run build
file: source/ci/build.yml
- task: list-files
file: source/ci/list-files.yml
构建.yml
---
platform: linux
image_resource:
type: docker-image
source: { repository: alexsuch/angular-cli, tag: '7.3' }
inputs:
- name: source
- name: npm-cache
path: /cache
outputs:
- name: artifact
run:
path: source/ci/build.sh
列表文件.yml
---
platform: linux
image_resource:
type: registry-image
source: { repository: busybox }
inputs:
- name: artifact
run:
path: ls
args: ['-la', 'artifact/']
编译文件
#!/bin/sh
mv cache/node_modules source
cd source
npm rebuild node-saas # temporary fix
npm run build_prod
cp -R dist ../artifact/
通常,您会在 TASKS 而不是 JOBS 之间将文件夹作为输入和输出传递(尽管有一些替代方案)
Concourse 是无国籍的,这就是其背后的理念。 但是,如果您想在作业之间传递某些内容,唯一的方法是使用大厅资源,并根据项目的性质,可以是从 git repo 到 s3 存储桶、docker 映像等的任何内容。您可以创建您的也拥有自定义资源。
例如,使用s3 大厅资源之类的东西
通过这种方式,您可以将工件推送到外部存储,然后在 get 步骤的下一个作业中再次使用它作为资源。 但这可能会造成一些不必要的复杂性,因为您理解您想要做的事情非常简单
根据我的经验,我发现有时大厅仪表板中工作计划的视觉方面给人的印象是工作计划应该按任务原子进行,这并不总是需要
希望有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.