Gitlab CI: create dist folder inside repository?

孤者浪人 提交于 2020-04-18 06:12:54

问题


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.

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?

Thanks in advance!


回答1:


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

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

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)

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

UPDATE If you want to upload the build artifact to an NPM registry, you could just build and push together.

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


来源:https://stackoverflow.com/questions/54343180/gitlab-ci-create-dist-folder-inside-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!