【发布时间】:2022-01-03 00:21:02
【问题描述】:
我正在尝试运行 gulp 并将编译后的文件保存到工件中,但我无法使其工作。
我的 gulp 文件在本地运行良好..
const process = require('process');
var css = {
src: process.cwd() + '/app/scss/style.scss',
dest: process.cwd() +'/public/stylesheets'
};
var gulp = require('gulp');
var sass = require('gulp-sass')(require('sass'));
function buildStyles() {
return gulp.src(css.src)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(css.dest));
};
exports.buildStyles = buildStyles;
这是我通过的 .yaml 文件,但是文件 my-build 是空的
stages: # List of stages for jobs, and their order of execution
- build
- deploy
# This job runs in the build stage, which runs first.
build-job:
stage: build
image: node:12.22.6-alpine
variables:
TZ: "Europe/Stockholm"
script:
- echo "Compiling the code..."
- mkdir my-build
- cd my-build
- npm i
- npm i --g gulp
- gulp buildStyles
- echo "Compile complete."
artifacts:
expire_in: 2 days
paths:
- my-build
allow_failure: false
deploy-job: # This job runs in the deploy stage.
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
script:
- echo "Deploying application..."
- echo "Application successfully deployed."
【问题讨论】:
-
你确定你真的在编译任何东西吗?你能显示构建的输出吗?也许我遗漏了一些东西,但是如果
gulp以相同的方式定位您的src和dest目录,我不知道这将如何工作。要么(1)你的输出目录不正确地相对于根目录(不是my-build或cwd)要么(2)你的src目录不正确地相对于cwd,导致当你从一个空目录运行gulp时没有编译,因为有my-build中没有 src 文件。尝试将tree $CI_PROJECT_DIR添加到构建的末尾以查看所有文件... -
@sytech 我用我得到的错误更新了帖子,关于树 $CI_PROJECT_DIR 我不确定我是否将它添加到正确的位置,但我收到一个错误 $ tree $CI_PROJECT_DIR /bin/sh :评估:第 128 行:树:未找到
-
您的映像中似乎未安装
tree。您可以安装树或改用ls -R $CI_PROJECT_DIR,但我想我在您的构建输出中看到了问题。