Skip to content

Instantly share code, notes, and snippets.

@RafalSladek
Last active July 18, 2021 11:59
Show Gist options
  • Save RafalSladek/0d92fa68cb985c698560 to your computer and use it in GitHub Desktop.
Save RafalSladek/0d92fa68cb985c698560 to your computer and use it in GitHub Desktop.
gitlab ci file for gulp build pipeline with the latest nodejs
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
@JGSolutions
Copy link

How does this work if there is no command for npm install gulp?

@rafaljanicki
Copy link

There is npm install command though, so it uses package.json file instead of direct install. IMO better approach

@JacobDB
Copy link

JacobDB commented Aug 29, 2016

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 :)

@JacobDB
Copy link

JacobDB commented Aug 29, 2016

Yep, just adding it to the before_script bit worked! Thanks for the excellent example!

@mbalex99
Copy link

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