Gitlab CI:在存储库中创建dist文件夹? [英] Gitlab CI: create dist folder inside repository?

查看:432
本文介绍了Gitlab CI:在存储库中创建dist文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近才开始使用gitlab CI来自动化一些构建/部署步骤。它可以完美地构建docker映像等,但是我想知道是否可以在构建步骤中在存储库中创建一个文件夹?例如,我现在正在制作一个npm实用程序包,但是我只是通过私有gitlab存储库(使用deploy令牌)将其导入其他项目中,但是该util包的代码是用es6编写的,需要进行编译到在其他软件包中使用的commonJS。我可以手动运行 npm run build ,它将输出包含已编译代码的dist文件夹。

I just recently started using gitlab CI to automate some build/deploy steps. It works perfectly to build docker images etc, but I was wondering if it's possible to create a folder in the repository during a build step? For example I'm now making an npm utility package, but I'm just importing it in my other projects via a private gitlab repo (using deploy token), but the code of the util package is written in es6 and needs to be transpiled to commonJS to be used in the other packages. Manually I can run npm run build and it will output a dist folder with the transpiled code.

我正在尝试(并研究)是否可以使用.gitlab-ci自动执行此构建过程,但到目前为止我什么都找不到。

I was trying (and researching) if it's possible to automate this build process using .gitlab-ci but so far I couldn't find anything.

有人知道我如何实现这一目标和/或这是否可能?

Anyone know how I can achieve this and/or if this is possible?

预先感谢!

推荐答案

不确定我是否正确回答了您的问题,因此请添加更多详细信息。

Not sure if I got your question correctly, so add more details if not.

当您的CI构建创建新文件夹或文件时,它们将被写入任务运行器的文件系统(我想这并不奇怪)。

When your CI build creates new folders or files, they are written to the task runner's file system (no surprise here, I assume).

如果要访问这些文件在Gitlab的网络UI中,您可以在构建作业中将它们定义为工件(请参见 https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html

If you want to access these files from Gitlab's web UI you can define them as artifacts in your build job (see https://docs.gitlab.com/ee/user/project/pipelines/job_artifacts.html)

您的构建作业看起来像这样(由内存编写的伪代码,未在Gitlab上进行测试):

Your build job would look something like that (pseudo code written by memory, not tested on Gitlab):

build:
  script:
  - npm run build
  artifacts:
    paths:
    - dist/
    expire_in: 1 week






更新如果要上传

build:
  script:
  - npm run build
  - npm publish <PARAMETERS>

这篇关于Gitlab CI:在存储库中创建dist文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆