Pipelines: Gulp gets permission denied

John Johnson June 2, 2017

I am new to Bitbucket pipelines. On a pipeline when my build script gets run I'm running into a permission denied error with gulp.

sh: 1: gulp: Permission denied

This fails my build. My gulp script writes to files in the repository. I was wondering how to remedy this.

Below is my gulpfile.js

var gulp = require('gulp'),
    rename = require('gulp-rename'),
    plumber = require('gulp-plumber'),
    gprint = require('gulp-print'),
    //notify = require('gulp-notify'),
    babel = require('gulp-babel'),
    gWatch = require('gulp-watch'),
    sourcemaps = require('gulp-sourcemaps');

gulp.task('build', ["build-es6", "build-src"]);

gulp.task("build-es6", function () {
    var trueBase = "public/assets/js/";
    gulp.src(trueBase + '/**/*-es6.js')
        .pipe(sourcemaps.init())
        .pipe(babel({sourceMaps: true, compact: false}))
        .pipe(rename(function (path) {
            path.basename = path.basename.replace(/-es6$/, '-es5');
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(trueBase))
        .pipe(gprint(function(filePath){ return "File processed: " + filePath; }));
});

gulp.task("build-src", function () {
    var trueBase = "src/es6/";
    var buildLocation = "public/assets/js/es6/"
    gulp.src(trueBase + '/**/*.js')
        .pipe(sourcemaps.init())
        .pipe(babel({sourceMaps: true, compact: false, modules: "umd"}))
        .pipe(rename(function (path) {
            path.basename = path.basename.replace(/-es6$/, '-es5');
        }))
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(buildLocation))
        .pipe(gprint(function(filePath){ return "File processed: " + filePath; }));
});

 

1 answer

1 accepted

1 vote
Answer accepted
John Johnson June 6, 2017

Before my pipeline script started out like this...

pipelines:
  default:
    - step:
        script: # Modify the commands below to build your repository.
          - npm install
- gulp build

Once I added the following line`npm install -g gulp` it worked fine.

pipelines:
  default:
- step: script: # Modify the commands below to build your repository. - npm install - npm install -g gulp
- gulp build

 

Ming Hann August 2, 2017

do you remove npm install -g gulp after that? running that every time I run my piplines is strange.

John Johnson August 2, 2017

@Ming Hann well I assumed bitbucket pipelines sets up a new isolated docker like container environment for each pipeline build. So if my assumptions correct the environment shouldn't have anything installed on it yet even globally because it creates a new one each time. I could be wrong though it may not create a whole new  environment each time. I haven't run my build without it, and I have sense moved to not using the pipelines at all so I can't really test it. If it doesn't you would be right and I would only have to run it once.

Have you tried it without it? It may work you could report back here and say if it does so or not so other people reading this in the future may know as well.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events