Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

post install task in package.json throws errors during rpm build task #19

Open
parky128 opened this issue Feb 2, 2017 · 0 comments
Open

Comments

@parky128
Copy link

parky128 commented Feb 2, 2017

We are using gulp-brass for RPM generation on our Jenkins build server.

Up until recently this has been working without any issue, however since migrating our application (web) from javascript to typescript, and as such updating dependencies in our package.json file we have started to get errors from the sourceTask API call made to the gulp-brass-npm module.

Here is our RPM gulp task we are currently using:

var path   = require('path'),
  gulp   = require('gulp'),
  rimraf = require('rimraf'),
  npm    = require('gulp-brass-npm'),
  brass  = require('gulp-brass'),
  merge2 = require('merge2'),
  pkg,
  options,
  rpm;

pkg = require('../package.json');
options = npm.getOptions(pkg);
options.installDir = '/opt/act/'+ options.name;
options.service = {
  type        : 'systemd',
  name        : options.name,
  description : options.description,
  exec        : '/bin/node index.js',
  user        : 'interact',
  group       : 'interact'
};

rpm = brass.create(options);

gulp.task('clean', function () {
  return gulp.src([ rpm.buildDir, '*.tgz', '*.log' ], { read: false })
    .pipe(brass.util.stream(function (file, done) {
      this.push(file);
      rimraf(file.path, done);
    }));
});

gulp.task('setup', [ 'clean' ], rpm.setupTask());
gulp.task('source', [ 'setup' ], npm.sourceTask(pkg, rpm));

gulp.task('files', ['source'], function () {

  var globs = [
    './config/**/*',
    './package.json'
  ];

  return merge2(
    gulp.src(globs, {base: '.'})
    , gulp.src('./dist/**/*')
  ).pipe(gulp.dest(path.join(rpm.buildRoot, options.installDir)))
    .pipe(brass.util.stream(function (file, done) {
      if (file.relative === 'bin/interact') {
        file.attr = [ '0775', 'root', 'root' ];
      }
      done(null, file);
    }))
    .pipe(rpm.files());
});

gulp.task('service', [ 'setup' ], function () {
  return gulp.src('gulp/gulp-brass-assets/interact.service')
    .pipe(brass.util.template(options.service))
    .pipe(brass.util.rename(options.service.name +'.service'))
    .pipe(gulp.dest(path.join(rpm.buildRoot, '/usr/lib/systemd/system')))
    .pipe(rpm.files());
});


gulp.task('binaries', [ 'files' ], npm.binariesTask(pkg, rpm));
gulp.task('spec', [ 'binaries', 'service' ], rpm.specTask());
gulp.task('build', [ 'spec' ], rpm.buildTask());

gulp.task('build-rpm', [ 'build' ], function () {
  console.log('build finished');
});

This task gets triggered from a Jenkins build job we have configured, the build log in Jenkins shows the following error:

+ gulp build-rpm
[16:26:36] Using gulpfile ~/jobs/interACT_Release/workspace/gulpfile.js
[16:26:36] Starting 'clean'...
[16:26:40] Finished 'clean' after 3.89 s
[16:26:40] Starting 'setup'...
[16:26:40] Finished 'setup' after 9.76 ms
[16:26:40] Starting 'source'...
[16:26:40] Starting 'service'...
[16:26:40] Finished 'service' after 92 ms
[16:27:52] 'source' errored after 1.2 min
[16:27:52] Error: Command failed: /bin/sh -c npm install
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] license should be a valid SPDX license expression
sh: typings: command not found

npm ERR! Linux 2.6.32-71.el6.x86_64
npm ERR! argv "/usr/local/bin/node" "/usr/bin/npm" "install"
npm ERR! node v4.2.6
npm ERR! npm  v2.14.12
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] postinstall: `typings install`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'typings install'.
npm ERR! This is most likely a problem with the interACT package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     typings install
npm ERR! You can get their info via:
npm ERR!     npm owner ls interACT
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/lib/jenkins/jobs/interACT_Release/workspace/brass_build/BUILD/npm-debug.log

    at ChildProcess.exithandler (child_process.js:213:12)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:821:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

Prior to calling this gulp task we perform other tasks to build our application, install dependencies (npm\bower install), etc, and move all built sources to a dist folder in our project directory. These build tasks work just fine on Jenkins, no errors get thrown when we perform an npm install prior to running our rpm build task.

We have also made sure that the typings npm module is installed globally on our jenkins environment.

In our package.json we have the following:

"scripts": {
    "test": "gulp test",
    "postinstall": "typings install"
  },

This post install task already gets run when we build our application into our dist folder prior to our rpm tasks being run.

I can see in the sourceTask source code in the gulp-brass-npm library how it executes an npm install command and sets the node environment variable to production.

I am thinking maybe I need to find a way to only run the post install task if the node environment variable is equal to development.

This is probably beyond the scope of your library, but I thought I'd ask here in case you have any experience with this and could offer further guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant