简体   繁体   English

如何从詹金斯运行 npm/grunt 命令

[英]how to run npm/grunt command from jenkins

I'm new to this area and was trying to run the following commands from jenkins:我是这个领域的新手,并试图从 jenkins 运行以下命令:

npm install
grunt quickStart

So far I've a jenkins running on a window machine as a window service and I've also installed NodeJs plugin for jenkins.到目前为止,我已经在窗口机器上运行了一个 jenkins 作为窗口服务,并且我还为 jenkins 安装了 NodeJs 插件。

However, I'm stuck and quit confused following instructions here , its asking me to to add one or mode nodeJs installation and I could not find those setting and not even sure if I even need them in the first place.但是,我被卡住了,并按照此处的说明感到困惑,它要求我添加一个或模式 nodeJs 安装,但我找不到这些设置,甚至不确定我是否一开始就需要它们。

Here is the bit that's asking me to do:这是要求我做的一点:在此处输入图片说明

I cannot see this setting for the jenkins job I create.我无法看到我创建的 jenkins 作业的此设置。 Is there an easy way to run those command in jenkins from a .bat or .sh script, a .bat would be recomended since I'm on window machine.有没有一种简单的方法可以从.bat.sh脚本在 jenkins 中运行这些命令,因为我在窗口机器上,所以推荐使用.bat

Note : I've already checked out a project using git in jenkins!!!注意:我已经在 jenkins 中使用 git 签出了一个项目!!!

Thanks谢谢

"its asking me to to add one or mode nodeJs installation and I could not find those setting and not even sure if I even need them in the first place. " “它要求我添加一个或模式 nodeJs 安装,但我找不到这些设置,甚至不确定我是否一开始就需要它们。
I don't think you need that I have pointed jenkins to the node installation folder an nothing more.., for this you go to Manage Jenkins->Configure System->NodeJS->NodeJS installations.. type in any name you like and point to where the node home folder is.我认为您不需要我将 jenkins 指向节点安装文件夹,仅此而已..,为此您转到管理 Jenkins-> 配置系统->NodeJS->NodeJS 安装.. 输入您喜欢的任何名称并指向节点主文件夹所在的位置。

节点主目录 ...cannot see this setting for the jenkins job I create... ...无法看到我创建的 jenkins 作业的此设置...

Once you have configure that in your jenkins configuration you should have that configuration available like so:一旦您在 jenkins 配置中进行了配置,您应该可以像这样使用该配置:

项目中的节点

...Is there an easy way to run those command in jenkins from a .bat or .sh script, a .bat would be recomended since I'm on window machine ...是否有一种简单的方法可以从 .bat 或 .sh 脚本在 jenkins 中运行这些命令,因为我在窗口机器上,所以推荐使用 .bat
I'm sorry don't get what commands are you referring to... so summarizing :很抱歉没有明白你指的是什么命令......总结一下:

  1. you have to tell jenkins where you have your node installation你必须告诉詹金斯你的节点安装在哪里
  2. use that configuration in your jobs在您的工作中使用该配置

hope this helps...希望这可以帮助...

我的方法是通过执行 shell,因为 nodejs 的构建工具是 npm,我只是写了一个 shell 脚本,指示 jenkins 在 jenkins 内的工作区目录中运行 npm install,在那里它克隆 git 存储库,然后压缩和如果成功,将包移动到另一个文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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