Pipelines: Gulp gets permission denied

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

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

 

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

@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 Join to answer
Community showcase
Piotr Plewa
Published Dec 27, 2017 in Bitbucket

Recipe: Deploying AWS Lambda functions with Bitbucket Pipelines

Bitbucket Pipelines helps me manage and automate a number of serverless deployments to AWS Lambda and this is how I do it. I'm building Node.js Lambda functions using node-lambda&nbsp...

662 views 0 4
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot