简体   繁体   中英

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:pass@corp.proxy.ip:port

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

fatal: unable to access ' http://gitlab-ci-token:xxxxxx@170.20.20.20: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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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