首页 > 解决方案 > 为什么 Gitlab 不能通过 CI 连接到仓库?

问题描述

我已经尝试了一些配置来修复多个错误,这个配置是目前最好的,但是它有一个我无法修复的错误。

设置.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                          https://maven.apache.org/xsd/settings-1.0.0.xsd">
    <servers>
        <server>
            <id>aqualix-repo</id>
            <username>${env.MAVEN_REPO_USER}</username>
            <password>${env.MAVEN_REPO_PASS}</password>
        </server>
    </servers>
</settings>

.gitlab-ci.yml

image: maven:latest

variables:
  MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"

cache:
  paths:
    - .m2/repository/
    - target/

build:
  stage: build
  script:
    - mvn $MAVEN_CLI_OPTS compile

test:
  stage: test
  script:
    - mvn $MAVEN_CLI_OPTS test

deploy:
  stage: deploy
  script:
    - mvn $MAVEN_CLI_OPTS deploy
  only:
    - master

pom.xml(父)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>de.aqualix.network</groupId>
  <artifactId>cloudsystem</artifactId>
  <packaging>pom</packaging>
  <version>1.0.0</version>
  <modules>
    <module>cloud-common</module>
    <module>cloud-core</module>
    <module>cloud-core-api</module>
    <module>cloud-proxy</module>
    <module>cloud-server</module>
    <module>cloud-server-api</module>
    <module>cloud-wrapper</module>
  </modules>
  <properties>
    <project.java.version>13</project.java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <dependency.netty.version>4.1.43.Final</dependency.netty.version>
    <dependency.guava.version>28.1-jre</dependency.guava.version>
    <dependency.gson.version>2.7</dependency.gson.version>
    <dependency.json-simple.version>1.1.1</dependency.json-simple.version>
    <dependency.typesafe-config.version>1.4.0</dependency.typesafe-config.version>
    <dependency.mongodb.version>3.11.2</dependency.mongodb.version>
  </properties>
  <repositories>
    <repository>
      <id>aqualix-repo</id>
      <url>https://repo.aqualix.de/repository/aqualix-repo/</url>
    </repository>
    <repository>
      <id>jcenter</id>
      <url>https://jcenter.bintray.com</url>
    </repository>
  </repositories>
  <distributionManagement>
    <repository>
      <id>aqualix-repo</id>
      <url>https://repo.aqualix.de/repository/aqualix-repo/</url>
    </repository>
  </distributionManagement>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>${project.java.version}</source>
          <target>${project.java.version}</target>
          <encoding>${project.build.sourceEncoding}</encoding>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

pom.xml(孩子)

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <parent>
    <artifactId>cloudsystem</artifactId>
    <groupId>de.aqualix.network</groupId>
    <version>1.0.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>cloud-common</artifactId>
  <dependencies>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>${dependency.guava.version}</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.typesafe</groupId>
      <artifactId>config</artifactId>
      <version>${dependency.typesafe-config.version}</version>
      <scope>compile</scope>
    </dependency>
      <dependency>
          <groupId>de.aqualix.network</groupId>
          <artifactId>annotations</artifactId>
          <version>1.0.0</version>
      </dependency>
  </dependencies>
  <build>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.2.2</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

错误

[ERROR] Failed to execute goal on project cloud-common: Could not resolve dependencies for project de.aqualix.network:cloud-common:jar:1.0.0: Failed to collect dependencies at de.aqualix.network:annotations:jar:1.0.0: Failed to read artifact descriptor for de.aqualix.network:annotations:jar:1.0.0: Could not transfer artifact de.aqualix.network:annotations:pom:1.0.0 from/to aqualix-repo (https://repo.aqualix.de/repository/aqualix-repo/): Transfer failed for https://repo.aqualix.de/repository/aqualix-repo/de/aqualix/network/annotations/1.0.0/annotations-1.0.0.pom: Connect to repo.aqualix.de:443 [repo.aqualix.de/45.95.52.78] failed: Connection timed out -> [Help 1]

错误是由于对存储库的授权失败,无法下载某些依赖项。

标签: mavencontinuous-integrationgitlab

解决方案


推荐阅读