srs / gradle-node-plugin

Gradle plugin for integrating NodeJS in your build. :rocket:
Apache License 2.0
864 stars 212 forks source link

Configure proxy for Jenkins #343

Open alibenmessaoud opened 5 years ago

alibenmessaoud commented 5 years ago

Hello,

I don't know if it is duplicated or no but my question is about node downloading and the use of the proxy. Well, my project has 2 modules, the first is frontend (React) and the second is backend (Java). My goal is to package the React sources in the resource of the backend project. Locally everything is fine but on Jenkins (Behind a proxy), errors are as shown below as the build fails:

> Task :frontend-bo:assemble
> Task :frontend-bo:compileTestJava NO-SOURCE
> Task :frontend-bo:processTestResources NO-SOURCE
> Task :frontend-bo:testClasses UP-TO-DATE
> Task :frontend-bo:test NO-SOURCE
> Task :frontend-bo:check UP-TO-DATE
> Task :frontend-bo:nodeSetup UP-TO-DATE

> Task :frontend-bo:npmSetup
npm ERR! code EHOSTUNREACH
npm ERR! errno EHOSTUNREACH
npm ERR! request to https://registry.npmjs.org/npm failed, reason: connect EHOSTUNREACH 104.16.22.35:443

npm ERR! A complete log of this run can be found in:
npm ERR!     /var/lib/jenkins/.npm/_logs/2019-07-31T14_22_05_568Z-debug.log

> Task :frontend-bo:npmSetup FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':frontend-bo:npmSetup'.
> Process 'command '/data/jenkins/workspace/commerce-frontend_PR-14-EBXQHC6O2GZBYJ73TBRYTBWUEEHVDY2LF2WNHVC2KAFDE6VHI3CQ/frontend-bo/.gradle/nodejs/node-v10.16.0-linux-x64/bin/node'' finished with non-zero exit value 1

It stays blocked on the Task :frontend-bo:npmSetup (npmSetup) task and it takes a long time before throwing the error. That's means it can't download npm from npmjs website.

Is there any way to configure the proxy on these tasks ?

I used this configuration too but it didn't work too.

Thanks.

alibenmessaoud commented 5 years ago

I close this ticket after I found a solution by setting proxy settings in the Jenkinfile and it works.

node {
   ...
   env.HTTP_PROXY = "http://proxy.threatpulse.net:8080"
   env.HTTPS_PROXY = "http://proxy.threatpulse.net:8080"
   ...
}