找不到当地的咕哝声

Unable to find local grunt

本文关键字:找不到      更新时间:2023-09-26

我让grunt在本地运行这个很好,但是在设置我的Jenkins服务器做同样的事情之后,我遇到了grunt无法找到grunt文件的问题。我可能错过了安装/配置一些东西吗?我无法从错误输出中判断出什么是错的,这是我在詹金斯盒子上得到的:

[user@buildserver] # ls

AUTHORS  CHANGELOG  coverage  Gruntfile.js  package.json  README.md  reports  spec  src

[user@buildserver] #繁重

grunt-cli: The grunt command line interface. (v0.1.6)
Fatal error: Unable to find local grunt.
If you're seeing this message, either a Gruntfile wasn't found or grunt
hasn't been installed locally to your project. For more information about
installing and configuring grunt, please see the Getting Started guide:
http://gruntjs.com/getting-started

这是Gruntfile.js

module.exports = function(grunt) {
  'use strict';
  // Project configuration.
  grunt.initConfig({
    jasmine : {
      src : 'src/**/*.js',
      options : {
        specs : 'spec/**/*.js',
        template : require('grunt-template-jasmine-istanbul'),
        templateOptions: {
          coverage: 'reports/coverage.json',
          report: 'reports/coverage'
        }
      }
    },
  });
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.registerTask('default', ['jasmine']);
};                                      

是否在Jenkins服务器上安装了grunt ?

npm install grunt

你可以从Jenkins管理界面设置一切,你不需要在本地安装grunt:)

安装Jenkins插件

  • Git Plugin - for Git
  • Git Client Plugin - for Git
  • Git参数插件- 用于Git标签
  • GitHub API Plugin - for GitHub
  • NodeJS Plugin - 集成常见的javascript工具NodeJS &npm

Git/Ant/Maven/NodeJS安装

  • Goto服务器/jenkins/配置
Git
  • Git -> Git安装->添加Git -> JGit
  • Git插件->全局配置用户名值= "Anthony Mckale",全局配置用户。email Value = "anthony.mckale@bskyb.com"
NodeJS
  • NodeJS->NodeJS安装-> Add NodeJS-> Name = "NodeJS 0.11.10",勾选"自动安装",选择"Install from nodejs.org",添加"grunt-cli"到全局安装包

TADA

希望git/nodejs和grunt都可以使用

查看插件wiki了解如何将grunt/node任务添加到jenkins作业-> https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

这真的很简单:)

不需要SSH登录,只需要Jenkins admin权限