Jenkins 与 Grunt 的集成 [英] Jenkins integration with Grunt

查看:27
本文介绍了Jenkins 与 Grunt 的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Windows Server 2008 R2 上设置了 Jenkins v1.550.它现在作为 http://localhost:8080 上的服务运行.我以管理员身份登录机器.我已经安装了 Node.js 并且可以从命令行运行npm".

I've setup Jenkins v1.550 on Windows Server 2008 R2. It runs as a service at http://localhost:8080 for now. I'm logged into the machine as an Administrator. I've installed Node.js and can run "npm" from the command line.

我还为 Jenkins 安装了 NodeJS 插件 v0.2.1.然后我进入 Jenkins 的配置系统"部分,向下滚动到 NodeJS 安装,单击添加 NodeJS"按钮,将NodeJS"作为名称,C:Program Files odejs"作为安装目录的路径.当我在插件页面上阅读它仅适用于 Linux 时,我没有选中自动安装"选项.

I've also installed the NodeJS plugin v0.2.1 for Jenkins. I then went into the Configure System section of Jenkins, scrolled down to NodeJS installations, clicked on Add NodeJS button, gave "NodeJS" as the name, and "C:Program Files odejs" as the path to the installation directory. I didn't check the "Install automatically" option as I read on the plugin page that it is only available to Linux.

然后我创建了一个新作业,点击了Provide Node & npm bin/folder to PATH"的复选框,为Execute Windows batch command"创建了一个新的构建步骤,并输入了node --version"和"grunt --version" 并保存它.

I then created a new job, clicked the checkbox that said "Provide Node & npm bin/ folder to PATH", created a new build step for "Execute Windows batch command" and typed in "node --version" and "grunt --version" and saved it.

我运行了作业,这是输出 -

I ran the job and this is the output -

Building in workspace C:Program Files (x86)JenkinsworkspaceTest_1.0
[Test_1.0] $ cmd /c call C:WindowsTEMPhudson1381541243088903083.bat

C:Program Files (x86)JenkinsworkspaceTest_1.0>node --version 
v0.10.24

C:Program Files (x86)JenkinsworkspaceTest_1.0>grunt --version 
'grunt' is not recognized as an internal or external command,
operable program or batch file.

C:Program Files (x86)JenkinsworkspaceTest_1.0>exit 9009 
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

它似乎无法找到 Jenkins 在(系统)下运行的用户帐户的 grunt-cli.我尝试全局安装 grunt cli (npm install -g grunt-cli) 和本地 grunt (npm install grunt).没有运气.

It looks like it's unable to find the grunt-cli for the user account Jenkins is running under (System). I tried to installing grunt cli globally (npm install -g grunt-cli) and also grunt locally (npm install grunt). No luck.

有人可以帮忙吗?

推荐答案

为了方便在机器上配置自安装的nodejs,我不得不推荐优秀的-> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

for nice easy to configure self-installed nodejs on the machine, i have to recommend the excellent -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

它将在机器上安装 nodejs 和 grunt,通过易于使用的 web 前端无需 shell

it will install nodejs and grunt on the machine, through easy to use web front end no shell required

jenkins 工作然后可以简单地运行 nodejs 构建步骤,嘿presto

jenkins jobs can then simply run nodejs build steps, hey presto

涉及的步骤:

a) 在您的 jenkins 实例上安装它 -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

a) install this on your jenkins instance -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

b) 在 jenkins 上创建 nodejs 安装

b) create a nodejs installation on jenkins

前往

http://URL_OF_JENKINS/jenkins/configure

  • NodeJS-> NodeJS 安装-> 添加NodeJS -> Name = "NodeJS 0.11.10",勾选"自动安装",选择"从nodejs.org 安装",在全局安装的包中添加"grunt-cli"

    c) 使用执行 NodeJS 脚本"构建任务创建作业

    c) create a job with "execute NodeJS script" build task

    var sys = require('sys');
    sys.puts('NodeJS Test');
    sys.puts('***************');
    sys.puts('helloworld');
    

    volia :)

    运行作业并查看 nodejs 脚本运行,

    run the job and see the nodejs script run,

    从他们的世界是你的牡蛎你可以通过勾选提供节点/npm bin文件夹到PATH"并运行执行shell"构建任务来使用grunt

    from their the world is your oyster you can use grunt by ticking "Provide Node/npm bin folder to PATH" and running a "execute shell" build task

    npm update
    grunt
    grunt --force reporting
    

    这篇关于Jenkins 与 Grunt 的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆