在Jenkins中构建Angular 2应用程序

时间:2017-03-06 21:16:39

标签: angular jenkins

我正在尝试构建类似于此的示例角度2应用: https://github.com/angular/quickstart.git快速启动。

我已将此项目克隆到我的存储库中,但除了在Jenkins上安装节点之外,我还不确定要修改哪些内容才能使构建成功。我需要为此安装任何依赖项吗?

我正在运行的唯一脚本是npm install,但作业仍然失败。

这是控制台结果:

[EnvInject] - Loading node environment variables.
Building remotely on r008p8p0c TPC (bxp2-prod linuxCleanUp) in workspace /bxp/jen/slave99/workspace/wmz-angular
 > /usr/bin/git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > /usr/bin/git config remote.origin.url https://git.url # timeout=10
Fetching upstream changes from https://git.url
 > /usr/bin/git --version # timeout=10
using GIT_ASKPASS to set credentials git
 > /usr/bin/git fetch --tags --progress https://git.url +refs/heads/*:refs/remotes/origin/*
 > /usr/bin/git rev-parse refs/remotes/origin/feature/ruth-3-6-17^{commit} # timeout=10
 > /usr/bin/git rev-parse refs/remotes/origin/origin/feature/ruth-3-6-17^{commit} # timeout=10
Checking out Revision 61164adcfa55d6ee096b6969b8c043187ae1fa88 (refs/remotes/origin/feature/ruth-3-6-17)
 > /usr/bin/git config core.sparsecheckout # timeout=10
 > /usr/bin/git checkout -f 61164adcfa55d6ee096b6969b8c043187ae1fa88
 > /usr/bin/git rev-list 61164adcfa55d6ee096b6969b8c043187ae1fa88 # timeout=10
[wmz-angular] $ /bxp/jen/slave99/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_0.12.9_v8/bin/node /tmp/hudson1546788266894720709.js
/tmp/hudson1546788266894720709.js:1
(function (exports, require, module, __filename, __dirname) { npm install
                                                                  ^^^^^^^
SyntaxError: Unexpected identifier
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
Build step 'Execute NodeJS script' marked build as failure
[BFA] Scanning build for known causes...
[BFA] No failure causes found
[BFA] Done. 0s
Finished: FAILURE

1 个答案:

答案 0 :(得分:0)

使用execute cmd/bash commands运行命令。 Execute NodeJS script期望.js文件像node index.js一样运行。

npm install不是有效的nodejs脚本,它只是用于安装npm模块的命令