简体   繁体   English

用于 angular 6 项目的 gitlab-ci 文件

[英]gitlab-ci file for an angular 6 project

I'm using angular 6 for my project.我正在为我的项目使用 angular 6。 This is my .gitignore file content:这是我的 .gitignore 文件内容:

# See http://help.github.com/ignore-files/ for more about ignoring files.
# compiled output
/dist
/tmp
/out-tsc

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage
/libpeerconnection.log
npm-debug.log
yarn-error.log
testem.log
/typings

# System Files
.DS_Store
Thumbs.db

Since the node_modules folder is not pushed into the git, how can I configure the gitlab-ci file for an automatic deployment?由于node_modules文件夹没有推送到git中,如何配置gitlab-ci文件进行自动部署?

If you install node packages with the following command:如果使用以下命令安装节点包:

npm install

Then you can use the same command in your build scripts:然后您可以在构建脚本中使用相同的命令:

my_job:
  before_script:
    - npm install
  script:
    - my_script

If your job is executed on a runner that has access to Internet and that has npm installed, this should work.如果您的工作是在可以访问 Internet 并安装了 npm 的运行程序上执行的,那么这应该可以工作。 Depending on how your deploy process works, you can either upload artifacts in GitLab, or call some other script that does this for you.根据部署过程的工作方式,您可以在 GitLab 中上传artifacts ,也可以调用其他一些脚本来为您执行此操作。

You can also use a cache in GitLab to reuse the node_modules folder between builds, example from here :您还可以使用 GitLab 中的缓存在构建之间重用 node_modules 文件夹, 示例如下:

image: node:latest

# Cache modules in between jobs
cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
  - node_modules/

before_script:
  - npm install

test_async:
  script:
  - node ./specs/start.js ./specs/async.spec.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM