我通过Node/Express有一个后端API,我刚刚开始学习CI/CD。我正在使用CircleCI,并设置了一个通用模板,但似乎无法弄清楚如何让CircleCI在此过程中创建一个构建文件夹。
下面是我的起始circle.yml
文件:
version: 2.1
jobs:
build:
docker:
- image: circleci/node:12.9.1
steps:
- checkout
- run: echo "npm installing"
- run: npm install
- run: npm run build
test:
docker:
- image: circleci/node:12.9.1
steps:
- checkout
- run: echo "Running test suite (TODO not currently applicable)"
complete:
docker:
- image: circleci/node:12.9.1
steps:
- checkout
- run: echo "Completed build & test process (TODO Add linting checks)"
workflows:
version: 2.1
build_test:
jobs:
- build
我有一个build
脚本在我的package.json
以下:"build": "tsc"
。在循环之外运行这个程序,它会根据我的需要编译构建文件夹。看看圆周上的状态,一切都过去了。但是分支没有实际的构建文件夹。
version: 2.1
jobs:
build:
docker:
- image: circleci/node:12.9.1
steps:
- checkout
- run: echo "npm installing"
- run: npm install
- run: npm run build
- persist_to_workspace:
root: ~/project
paths:
- build
test:
docker:
- image: circleci/node:12.9.1
steps:
- checkout
- run: echo "Running test suite (TODO not currently applicable)"
complete:
docker:
- image: circleci/node:12.9.1
steps:
- checkout
- run: echo "Completed build & test process (TODO Add linting checks)"
deploy:
docker:
- image: circleci/node:12.9.1
steps:
- attach_workspace:
at: ~/project
- run:
name: Deployment Step
command: |
#!/bin/sh
ls build
workflows:
version: 2.1
build_test:
jobs:
- build
- test:
requires:
- build
- complete:
requires:
- test
- deploy:
requires:
- complete
当构建脚本运行时,创建一个名为build的文件夹,您可以持久化该文件夹以便在其他作业中使用。在名为deploy的新作业中,它调用构建文件夹所在的文件夹,因此现在您可以将该文件夹发送到服务器。