简体   繁体   中英

Jenkins grunt compass ENOENT No such file or directory @ realpath_rec

I am working on an existing project to replace bower with yarn and upgrading angularjs from 1.2.9 to 1.3.0

I've got it working on my local system but it fails on jenkins when running deploy grunt task with a filepath issue, the weird thing is on jenkins it complains with my local path

Errno::ENOENT on line ["33"] of /var/lib/jenkins/.rvm/gems/ruby-2.3.3/gems/compass-1.0.3/lib/compass/exec/global_options_parser.rb: No such file or directory @ realpath_rec - /home/leonidas

/home/leonidas is my local path

This is my Gruntfile.js ,

'use strict';
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
var serveStatic = require('serve-static');

module.exports = function (grunt) {
  // load all grunt tasks
  require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

  // configurable paths
  var yeomanConfig = {
    app: 'app',
    dist: '../public'
  };

  try {
    yeomanConfig.app = require('./package.json').appPath || yeomanConfig.app;
  } catch (e) {}

  grunt.initConfig({
    ngtemplates: {
      myApp: {
        options: {
          base: 'app',
          concat: '<%= yeoman.dist %>/scripts/scripts.js'
        },
        src: ['app/views/**/*.html'],
        dest: '.tmp/template.js'
      }
    },
    yeoman: yeomanConfig,
    watch: {
      all : {
        options : { livereload: true },
        files: [
          '<%= yeoman.app %>/{,*/}*.html',
          '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
          '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
          '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
        ],
        tasks: ['jshint']
      }
    },
    connect: {
      proxies: [{
        context: '/api',
        host: '127.0.0.1',
        port: 5000,
        https: false,
        changeOrigin: false
      }, {
        context: '/public/api',
        host: '127.0.0.1',
        port: 5000,
        https: false,
        changeOrigin: false
      }, {
        context: '/print',
        host: '127.0.0.1',
        port: 5000,
        https: false,
        changeOrigin: false
      }, {
        context: '/users',
        host: '127.0.0.1',
        port: 5000,
        https: false,
        changeOrigin: false
      }],
      livereload: {
        options: {
          port: 9000,          
          hostname: '0.0.0.0',
          middleware: function () {
            return [
              require('connect-livereload')(),
              proxySnippet,
              serveStatic('.tmp'),
              serveStatic('test'),
              serveStatic(yeomanConfig.app)
            ];
          }
        }
      },
      test: {
        options: {
          port: 9001,
          middleware: function () {
            return [
              serveStatic('.tmp'),
              serveStatic('test')
            ];
          }
        }
      },
      teste2e: {
        options: {
          port: 9002,
          hostname: 'localhost',
          middleware: function () {
            return [
              proxySnippet,
              serveStatic('.tmp'),
              serveStatic('test'),
              serveStatic(yeomanConfig.app)
            ];
          }
        }
      }
    },
    open: {
      server: {
        url: 'http://localhost:<%= connect.livereload.options.port %>'
      }
    },
    clean: {
      options: {
        force: true
      },
      dist: ['.tmp', '<%= yeoman.dist %>/*'],
      server: '.tmp'
    },
    jshint: {
      options: {
        jshintrc: '.jshintrc'
      },
      all: [
        'Gruntfile.js',
        '<%= yeoman.app %>/scripts/{,*/}*.js'
      ]
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true
      },
      dev: {
        configFile: 'karma.conf.js',
        singleRun: false
      },
      e2e: {
        configFile: 'karma-e2e.conf.js',
        singleRun: true
      }
    },
    coffee: {
      dist: {
        files: {
          '.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
        }
      },
      test: {
        files: [{
          expand: true,
          cwd: '.tmp/spec',
          src: '*.coffee',
          dest: 'test/spec'
        }]
      }
    },
    compass: {
      dist: {
        options: {
          sassDir: '<%= yeoman.app %>/styles',
          cssDir: '.tmp/styles',
          imagesDir: '<%= yeoman.app %>/images',
          javascriptsDir: '<%= yeoman.app %>/scripts',
          fontsDir: '<%= yeoman.app %>/styles/fonts',
          importPath: '<%= yeoman.app %>/components',
          relativeAssets: true
        }
      },
      server: {
        options: {
          debugInfo: true
        }
      }
    },
    concat: {
      dist: {
        files: {
          '<%= yeoman.dist %>/scripts/scripts.js': [
            '.tmp/scripts/{,*/}*.js',
            '<%= yeoman.app %>/scripts/{,*/}*.js'
          ]
        }
      }
    },
    useminPrepare: {
      html: '<%= yeoman.app %>/index.html',
      options: {
        dest: '<%= yeoman.dist %>'
      }
    },
    rev: {
      files: {
        src: ['<%= yeoman.dist %>/lib/components.js', '<%= yeoman.dist %>/lib/components-ie8.js', '<%= yeoman.dist %>/lib/components-ie.js', '<%= yeoman.dist %>/scripts/scripts.js', '<%= yeoman.dist %>/styles/main.css']
      }
    },
    usemin: {
      html: ['<%= yeoman.dist %>/{,*/}*.html'],
      css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
      options: {
        dirs: ['<%= yeoman.dist %>']
      }
    },
    imagemin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>/images',
          src: '{,*/}*.{png,jpg,jpeg}',
          dest: '<%= yeoman.dist %>/images'
        }]
      }
    },
    cssmin: {
      dist: {
        files: {
          '<%= yeoman.dist %>/styles/main.css': [
            '.tmp/styles/{,*/}*.css',
            '<%= yeoman.app %>/styles/{,*/}*.css'
          ]
        }
      }
    },
    htmlmin: {
      dist: {
        options: { },
        files: [{
          expand: true,
          cwd: '<%= yeoman.app %>',
          src: ['*.html', 'views/*.html'],
          dest: '<%= yeoman.dist %>'
        }]
      }
    },
    ngmin: {
      dist: {
        files: [{
          expand: true,
          cwd: '<%= yeoman.dist %>/scripts',
          src: '*.js',
          dest: '<%= yeoman.dist %>/scripts'
        }]
      }
    },
    uglify: {
      dist: {
        files: {
          '<%= yeoman.dist %>/scripts/scripts.js': ['<%= yeoman.dist %>/scripts/*.js']
        }
      }
    },
    copy: {
      dist: {
        files: [{
          expand: true,
          dot: true,
          cwd: '<%= yeoman.app %>',
          dest: '<%= yeoman.dist %>',
          src: [
            '*.{ico,txt}',
            '.htaccess',
            'fonts/**/*',
            'scriptx/**/*',
            'lib/**/*',
            'images/{,*/}*.{gif,webp,svg}'
          ]
        }]
      }
    }
  });

  grunt.registerTask('server', [
    'clean:server',
    'coffee:dist',
    'compass:server',
    'configureProxies',
    'connect:livereload',
    'open',
    'watch'
  ]);

  grunt.registerTask('test', [
    'clean:server',
    'coffee',
    'compass',
    'connect:test',
    'karma:unit'
  ]);

  grunt.registerTask('test-e2e', [
    'clean:server',
    'coffee',
    'compass',
    'configureProxies',
    'connect:teste2e',
    'karma:e2e'
  ]);

  grunt.registerTask('deploy', [
    'clean:dist',
    'coffee',
    'compass:dist',
    'useminPrepare',
    'imagemin',
    'cssmin',
    'htmlmin',
    'ngtemplates',
    'concat',
    'ngmin',
    'uglify',
    'copy',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('build', [
    'clean:dist',
    'jshint',
        'karma:unit',
    'compass:dist',
    'useminPrepare',
    'imagemin',
    'cssmin',
    'htmlmin',
    'ngtemplates',
    'concat',
    'ngmin',
    'uglify',
    'copy',
    'rev',
    'usemin'
  ]);

  grunt.registerTask('default', ['build']);
};

Just to clarify I'm not a front-end dev, I'm learning as I'm doing things.

A lot of time has passed from the question, I answer for those who encounter this problem.

In my case was due to the wrong position of the bower_components folder. Considering as example the Gruntfile.js pasted in the question, the importPath for compass is:

importPath: '<%= yeoman.app %>/bower_components',

That is /app/bower_components directory. Make sure that the output of bower install command is in /app folder. In most cases just add or check the .bowerrc containing the following:

{
  "directory": "app/bower_components"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM