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

This widget could not be displayed.

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 Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 10, 2018 in Bitbucket

What is your #1 piece of advice to new users getting started using Bitbucket?

Hello Community! My name is Claire Maynard, and I’m a Product Marketing Manager on the Bitbucket team. I’m interested in hearing what advice or tips you have for new users getting started on ...

243 views 14 2
Join discussion

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