为什么Jenkins由于Sass文件无法在angular4项目中下载而无法构建?

时间:2017-06-15 07:30:01

标签: angular jenkins angular-cli

我正在尝试使用angular cli和Jenkins构建一个angular4项目。该项目在我的MacBook Pro上本地构建良好,但在Jenkins中运行构建脚本时失败并引发以下错误。似乎问题是由Jenkins设置或其他东西引起的,如果Jenkins在我的本地计算机上构建良好,它应该能够构建项目。这是错误消息。怎么解决这个问题?错误信息很长,所以我只包括我认为最相关的部分。谢谢!

> node-sass@4.5.3 install /ci/work/jenkins/workspace/vardgivare-frontend/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-48_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-48_binding.node": 

ETIMEDOUT

Timed out attemping to establish a remote connection

Hint: If github.com is not accessible in your location
      try setting a proxy via HTTP_PROXY, e.g. 

      export HTTP_PROXY=http://example.com:1234

or configure npm proxy via

      npm config set proxy http://example.com:8080

> node-sass@4.5.3 postinstall /ci/work/jenkins/workspace/vardgivare-frontend/node_modules/node-sass
> node scripts/build.js

1 个答案:

答案 0 :(得分:1)

您需要设置代理

对于GitHub,命令是

git config --global http.proxy whatever-url

git config --global https.proxy whaterver-url

您甚至需要在节点级别执行这些操作,因为当它尝试执行npm安装时,它将需要这些。

命令是

npm config set proxy whatever-url

npm config set https-proxy whatever-url