Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues with proxy in Gitlab CI using Docker runner

I want to package my Maven/Java app in a Docker Gitlab CI runner.

I'm behind a corporation proxy. This is my .gitlab-ci.yml:

image: maven:3-jdk-7

build:
  script: "mvn clean package -B"

When a build is triggered, I get this error (in the Gitlab build console):

Unknown host repo.maven.apache.org: Name or service not known -> [Help 1]

Then, I have added

variables:
  http_proxy: http://user:[email protected]:port

to the .gitlab-ci.yml. But I get another error:

fatal: unable to access 'http://gitlab-ci-token:[email protected]:8080/myapp.git/': The requested URL returned error: 504

When I registered the Docker runner, Docker image selected was maven:3-jdk-7.

I have just tried adding no_proxy variable with 172.20.20.20 as value (Gitlab IP) but I get the same error (the first one.)

How can I solve it? Is there a way to force the Docker runner (container) to use --net=host?

like image 940
Héctor Avatar asked Mar 31 '16 13:03

Héctor


1 Answers

What I did was I had to open up the mvnw document. Inside of it I found this line

MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"

In between the ')' and the $MAVEN_OPTS I placed the

-Dhttps.proxyHost=yourHost -Dhttps.proxyPort=yourPort

arguments. This worked for me. Hope this helps. I didn't need the "variables" section you described above.

like image 183
Matthew Zackschewski Avatar answered Sep 27 '22 18:09

Matthew Zackschewski