简体   繁体   English

在 Gitlab CI/CD 上构建的 Vue.js 不会在 `/dist` 目录中产生任何工件

[英]Vue.js build on Gitlab CI/CD not producing any artifacts in `/dist` directory

I'm attempting to add a build stage to my CI/CD pipeline that I'm running on Gitlab.com.我正在尝试向我在 Gitlab.com 上运行的 CI/CD 管道添加一个build阶段。 The build seemingly 'completes' without error, but the /dist directory remains empty after the build.构建看似“完成”没有错误,但/dist目录在构建后仍然是空的。

Here's the relevant config from my gitlab-ci.yml file:这是我的gitlab-ci.yml文件中的相关配置:

在此处输入图片说明

But the result as seen in the runner logs is an empty /dist directory:但是在运行日志中看到的结果是一个空的/dist目录:

在此处输入图片说明

The runner reports that it found one matching files , but I'm assuming that it's counting the empty /dist dir as the file that it found because the directory itself is empty, which causes my deploy stage to fail when it tries to upload the missing artifacts.运行程序报告说它found one matching files ,但我假设它将空的/dist目录计为它找到的文件,因为目录本身是空的,这会导致我的deploy阶段在尝试上传丢失的文件时失败文物。

Does anyone have any idea what's going on here?有谁知道这里发生了什么?

The build seems to succeed just fine, but there's no resulting files in the /dist directory.构建似乎成功了,但/dist目录中没有结果文件。 And with that in mind, where are they going then?考虑到这一点,他们要去哪里?

I've tried many different representations of the path, and even tried utilizing the process.env.CI_PROJECT_DIR var as the value in my webpack.config file(s) but I can't get the artifacts to land in the /dist dir.我尝试了许多不同的路径表示,甚至尝试使用process.env.CI_PROJECT_DIR var 作为我的 webpack.config 文件中的值,但我无法将工件放置在/dist目录中。

When I download the artifacts .zip file using the Gitlab.com console I just end up with an empty folder.当我使用 Gitlab.com 控制台下载 artifacts .zip 文件时,我最终得到了一个空文件夹。

Thanks in advance for any light anyone can shed on this.提前感谢任何人都可以对此有所了解。

There's probably nothing wrong with the artifacts creation, but there could be something wrong with the npm run build part of the job. artifacts创建可能没有任何问题,但作业的npm run build部分可能有问题。 I usually get this problem when npm run build fails (for example, the CI env does not have the proper packages installed in node_modules ), so nothing gets put under the dist folder.npm run build失败时,我通常会遇到这个问题(例如,CI env 没有在node_modules 中安装正确的包),所以什么都没有放在dist文件夹下。 The problem is that Gitlab CI will not abort the job when npm run build fails, and it would still continue up to the artifacts creation, which as you reported, will zip-up an empty dist folder.问题在于,当npm run build失败时,Gitlab CI不会中止作业,并且它仍然会继续创建artifacts ,正如您所报告的那样,它将压缩一个空的dist文件夹。

Check that the npm run build part of the job actually succeeds.检查作业的npm run build部分是否实际成功。

I don't know much about npm running on gitlab ci, but it may be what you need.我对在 gitlab ci 上运行的 npm 了解不多,但它可能正是您所需要的。 Gitlab CI: create dist folder inside repository? Gitlab CI:在存储库中创建 dist 文件夹?

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

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