无法在Jenkins上启动PhantomJs

时间:2015-07-29 23:41:08

标签: jenkins gruntjs phantomjs jenkins-plugins karma-jasmine

我正试图在我的詹金斯农场运行咕噜咕噜的业力,但我一直收到这个错误

   [4mRunning "karma:continuous" (karma) task[24m
    [32m29 07 2015 19:17:24.976:INFO [karma]: [39mKarma v0.13.3 server started at http://localhost:9876/
    [32m29 07 2015 19:17:24.984:INFO [launcher]: [39mStarting browser PhantomJS
    [33m29 07 2015 19:18:25.017:WARN [launcher]: [39mPhantomJS have not captured in 60000 ms, killing.
    [33m29 07 2015 19:18:27.024:WARN [launcher]: [39mPhantomJS was not killed in 2000 ms, sending SIGKILL.
    [33m29 07 2015 19:18:29.028:WARN [launcher]: [39mPhantomJS was not killed by SIGKILL in 2000 ms, continuing.
    Warning: Task "karma:continuous" failed. Use --force to continue.  

这是我的Gruntfile.js

/*global module:false*/
module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    // Metadata.
    meta: {
      version: '0.1.1'
    },
    banner: '/*! PROJECT_NAME - v<%= meta.version %> - ' +
      '<%= grunt.template.today("yyyy-mm-dd") %>\n' +
      '* http://PROJECT_WEBSITE/\n' +
      '* Copyright (c) <%= grunt.template.today("yyyy") %> ',
    // Task configuration.
    concat: {
      main: {
        options: {
          banner: '<%= banner %>',
          stripBanners: true
        },
        dist: {
          src: ['lib/**/*.js'],
          //src: ['lib/**/broadcast.js'],
          dest: 'dist/concat-main-app.js',
          //dest: 'dist/concat-broadcast.js',
          nonull:true
        }
      },
      modules : {
        options: {
          banner: '<%= banner %>',
          stripBanners: true
        },
        dist: {
          src: ['bower_components/angular/angular.min.js'],
          //src: ['lib/**/broadcast.js'],
          dest: 'dist/concat-angular.js',
          //dest: 'dist/concat-broadcast.js',
          nonull:true
        }   
      },
      build: {
            files: {
                'dist/concat-main-app.js': ['lib/**/*.js'],
                'dist/concat-angular.js': 
                    [ 
                      'bower_components/angular/angular.min.js',
                      'bower_components/angular-route/angular-route.min.js',
                      'bootstrap-3.3.4-dist/js/bootstrap.min.js',
                      'ui-bootstrap-custom-0.12.1.min.js',
                      'ui-bootstrap-custom-tpls-0.12.1.min.js',
                      'bower_components/summernote/dist/summernote.min.js',
                      'bower_components/angular-summernote/dist/angular-summernote.js',
                      'bower_components/angular-ui-select/dist/select.min.js',
                      'bower_components/angular-sanitize/angular-sanitize.min.js'
                    ]
            }
      },
    },
    uglify: {
      options: {
         banner: '<%= banner %>'
       },
        build: {
            files: {
                'dist/main-app.min.js': ['<%= concat.main.dist.dest %>'],
                'dist/checklist-model.min.js': ['bower_components/checklist-model/checklist-model.js']
            }
        }
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc',
        loopfunc: true,
        curly: true,
        eqeqeq: true,
        immed: true,
        latedef: true,
        newcap: true,
        noarg: true,
        sub: true,
        undef: true,
        unused: true,
        boss: true,
        eqnull: true,
        jasmine: true,
        devel:true,
        asi:true,
        lastsemic: true,
        globals: {
          jQuery: true
        }
      },
      gruntfile: {
        src: './Gruntfile.js'
      },
      lib_test: {
        src: ['lib/controller/**/*.js']
      }
    },
    cssmin: {
      options: {
        shorthandCompacting: false,
        roundingPrecision: -1
      },
      target: {
        files: {
          'dist/bittrove-css.min.css': 
          [
            '../css/custom.css', 
            //'../css/select2-3-5-2.css', 
            //'bootstrap-3.3.4-dist/css/bootstrap.css'
          ]
        }
      }
    },
    karma: {
      unit: {
        configFile: './karma.conf.js'
      },
      continuous: {
        configFile: './karma.conf.js',
        singleRun: true,
        browsers: ['PhantomJS']
      }
    },
    watch: {
      gruntfile: {
        files: '<%= jshint.gruntfile.src %>',
        tasks: ['jshint:gruntfile']
      },
      lib_test: {
        files: '<%= jshint.lib_test.src %>',
        tasks: ['jshint:lib_test']
      }
    }
  });

  // These plugins provide necessary tasks.
  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-karma'); 

  // Default task.
  grunt.registerTask('default', [ 'concat', 'uglify','cssmin','karma:continuous']);

};

这是我的karma.conf.js

// Karma configuration
// Generated on Tue Mar 24 2015 19:54:10 GMT-0500 (CDT)

module.exports = function(config) {
  config.set({

    // base path that will be used to resolve all patterns (eg. files, exclude)
    basePath: './',


    // frameworks to use
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
    frameworks: ['jasmine'],


    // list of files / patterns to load in the browser //ORDER IS IMPORTANT!
    files: [      
        "bower_components/angular/angular.min.js",
        "bower_components/angular-mocks/angular-mocks.js",
        //"dist/main-app.min.js",
        "lib/**/*.js",
        "test/*.js",
       // "bower_components/angular-latest/test/**/*.js"
    ],


    // list of files to exclude
    exclude: [
        "bower_components/angular-latest/test/e2e/**",
        "bower_components/angular-latest/test/helpers/**"
    ],


    // preprocess matching files before serving them to the browser
    // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
    preprocessors: {
    },


    // test results reporter to use
    // possible values: 'dots', 'progress'
    // available reporters: https://npmjs.org/browse/keyword/karma-reporter
    reporters: ['progress'],


    // web server port
    port: 9876,


    // enable / disable colors in the output (reporters and logs)
    colors: true,


    // level of logging
    // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
    logLevel: config.LOG_INFO,


    // enable / disable watching file and executing tests whenever any file changes
    autoWatch: false,

    plugins : [
            'karma-jasmine',
            'karma-phantomjs-launcher'
    ],


    // Continuous Integration mode
    // if true, Karma captures browsers, runs the tests and exits
    singleRun: true
  });
};

这是我的Jenkins shell exe:

cd src/app/public/js
npm install
bower install 
npm list

我使用NodeJs插件在我的Jenkins服务器场上安装了nodejs。 我有节点0.10.36,bower 1.4.1,grunt-cli v0.1.13,grunt v0.4.5。 Karma 0.13.3

1 个答案:

答案 0 :(得分:0)

在更新nodejs和karma模块后,我遇到了同样的问题。 删除PHANTOMJS_BIN环境变量终于解决了我的问题。