1

我正在开发一个现有项目来替换boweryarn升级angularjs1.2.91.3.0

我已经让它在我的本地系统上运行,但是jenkins在运行deploygrunt 任务时出现文件路径问题时失败,奇怪的是在 jenkins 上它抱怨我的本地路径

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是我的本地路径

这是我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']);
};

只是为了澄清我不是前端开发人员,我在做事时正在学习。

4

1 回答 1

0

这个问题已经过去了很多时间,我为遇到这个问题的人回答。

在我的情况下是由于bower_components文件夹的位置错误。以粘贴在问题中的 Gruntfile.js 为例,importPathfor 指南针是:

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

那是/app/bower_components目录。确保bower install命令的输出在/app文件夹中。在大多数情况下,只需添加或检查.bowerrc包含以下内容:

{
  "directory": "app/bower_components"
}
于 2018-11-28T17:43:57.913 回答