Last active
July 18, 2021 11:59
-
-
Save RafalSladek/0d92fa68cb985c698560 to your computer and use it in GitHub Desktop.
gitlab ci file for gulp build pipeline with the latest nodejs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
image: node:latest | |
cache: | |
paths: | |
- node_modules/ | |
before_script: | |
- npm install | |
stages: | |
- build_deploy | |
build_&_deploy_app: | |
stage: build_deploy | |
only: | |
- master | |
script: | |
- gulp build -production | |
- gulp deploy |
There is npm install command though, so it uses package.json file instead of direct install. IMO better approach
I'm just starting to learn about CI; I've got everything set up and mostly running, except my build is failing with the error:
/bin/bash: line 42: gulp: command not found
ERROR: Build failed: exit code 1
I'm thinking it's because there's no npm -i -g gulp
, but how would I even do that? Do I just add that command in the before_script
bit?
Will try some stuff and report back if I figure it out :)
Yep, just adding it to the before_script
bit worked! Thanks for the excellent example!
If you have a task like gulp.task('upload') in you gulpfile you can do this:
var gulp = require('gulp');
gulp.task("upload", function () {
//some upload task
});
You can have a .gitlab-ci.yml like so:
image: node:latest
cache:
paths:
- node_modules/
before_script:
- npm install
stages:
- build_deploy
build_&_deploy_app:
stage: build_deploy
only:
- master
script:
- node_modules/gulp/bin/gulp.js --gulpfile ./gulpfile.js upload
Make sure you have gulp in your package.json (truncated version below)
{
"devDependencies": {
"gulp": "3.9.1",
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How does this work if there is no command for npm install gulp?