【问题标题】:Gitlab-runner docker executor trying to download maven dependenciesGitlab-runner docker executor试图下载maven依赖项
【发布时间】:2018-02-22 14:38:43
【问题描述】:

我有一个 gitalb-​​runner 作为 docker 容器运行。 这是 mvn test 命令的失败工作:

Running with gitlab-runner 10.4.0 (857480b6)
on mvn-build (ae93a255)
Using Docker executor with image maven:3.3.9-jdk-8 ...
Using docker image sha256:b4b185fdfd711067c07e8a1df1257645aff2781402dc147e52d9a09636f9a139 for predefined container...
Pulling docker image maven:3.3.9-jdk-8 ...
Using docker image maven:3.3.9-jdk-8 ID=sha256:9997d8483b2fc521a4159feab922546dda0c5c22b5084f86dfab48f123ae4364 for build container...
Running on runner-ae93a255-project-2-concurrent-0 via 49682264df2f...
Fetching changes...
HEAD is now at e197d19 Fixed yml
Checking out e197d191 as dev...
Skipping Git submodules setup
$ echo "Building project with maven"
Building project with maven
$ mvn $MAVEN_OPTS test
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building rest-client
[INFO] ------------------------------------------------------------------------
Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 21.626 s
[INFO] Finished at: 2018-02-21T15:00:07+00:00
[INFO] Final Memory: 9M/118M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6: Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.12.215] failed: Connection refused (Connection refused) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
ERROR: Job failed: exit code 1

我的问题是我真的需要设置代理并连接互联网吗? 还是有任何其他选项可以为 maven 提供缺少的插件?

我提到我已经在 config.toml 中配置了 repo 映射:

oncurrent = 1
check_interval = 0

[[runners]]
  name = "mvn-build"
  url = "http://192.168.233.128/"
  token = "ae93a255f60d0e1abdb26cc9f72cd5"
  executor = "docker"
  [runners.docker]
    tls_verify = false
    image = "maven:3.3.9-jdk-8"
    privileged = false
    disable_cache = false
    volumes = ["/cache","/var/run/docker.sock:/var/run/docker.sock","/root/.m2/repository/:/root/.m2/repository/"]
    shm_size = 0
  [runners.cache]

【问题讨论】:

    标签: docker continuous-integration gitlab gitlab-ci-runner


    【解决方案1】:

    Maven 插件在本地缓存在 .m2/repository 文件夹中,因此您可以确保所有需要的插件和依赖项在托管 gitlab-runner 的服务器/VM 的 /root/.m2/repository/ 文件夹中可用。例如通过在服务器上运行一次mvn test。

    您可能希望避免这种情况,因为任何时候更改依赖项时都需要 ssh 进入构建服务器并在那里更新本地 Maven 缓存。

    考虑到这一点,设置一次代理和互联网连接不会那么糟糕。除非您有其他一些限制和/或希望避免从外部 maven 存储库下载依赖项。 在这种情况下,最好在组织内设置一个 Maven 存储库,该存储库缓存来自 Maven 中心的任何外部依赖项

    【讨论】:

      猜你喜欢
      • 2017-10-28
      • 1970-01-01
      • 1970-01-01
      • 2018-08-29
      • 2023-03-15
      • 1970-01-01
      • 2021-07-04
      • 2013-05-22
      • 2020-07-06
      相关资源
      最近更新 更多