Бегун Maven и Gitlab с репозиторием nexus: 401 неавторизованный - PullRequest
1 голос
/ 25 мая 2020

У меня есть конфигурация с maven, gitlab-runner и nexus. Конвейер работает нормально, если gitlab-runner относится к исполнителю оболочки типа. Но если я изменю gitlab-runner на один из исполнителей типа docker. Затем после загрузки множества зависимостей из репозитория nexus выдается исключение из-за 401 Unauthorized. Соответствующие части конфигурации:

настройки. xml (без паролей)

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <pluginGroups>
    <pluginGroup>org.openclover</pluginGroup>
  </pluginGroups>

  <servers>
    <server>
      <id>nexus-snapshots</id>
      <username>theusername</username>
      <password></password>
    </server>
    <server>
      <id>nexus-releases</id>
      <username>theusername</username>
      <password></password>
    </server>
    <server>
      <id>central</id>
      <username>theusername</username>
      <password></password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>central</id>
      <name>central</name>
      <url>https://<my_domain>/repository/maven-group/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

</settings>

pom. xml:

<project>
...
  <!-- Repositories -->

  <repositories>
    <repository>
      <id>central</id>
      <url>https://<my_domain>/repository/maven-group/</url>
    </repository>
  </repositories>

  <!-- //////////////// -->

  <!-- Distribution Management -->

  <distributionManagement>
    <snapshotRepository>
      <id>nexus-snapshots</id>
      <url>https://<my_domain>/repository/maven-snapshots/</url>
    </snapshotRepository>
    <repository>
      <id>nexus-releases</id>
      <url>https://<my-domain>/repository/maven-releases/</url>
    </repository>
  </distributionManagement>
...
</project>

  <!-- ///////////// -->

gitlab- ci.yml:

image: maven:3.6.3-jdk-11


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

stages:
  - test

codetest:
  stage: test
  script:
    - mvn $MAVEN_CLI_OPTS clean clover:setup test clover:aggregate clover:save-history clover:clover clover:log

И, наконец, исключение:

 Downloading from central: https://<my_domain>/repository/maven-group/io/quarkus/quarkus-oidc/1.4.2.Final/quarkus-oidc-1.4.2.Final.jar
Downloading from central: https://<my_domain>/repository/maven-group/io/quarkus/quarkus-resteasy-jsonb/1.4.2.Final/quarkus-resteasy-jsonb-1.4.2.Final.jar
Downloading from central: https://<my_domain>/repository/maven-group/io/quarkus/quarkus-hibernate-validator/1.4.2.Final/quarkus-hibernate-validator-1.4.2.Final.jar
[ERROR] Tests run: 2, Failures: 0, Errors: 1, Skipped: 1, Time elapsed: 7.461 s <<< FAILURE! - in org.duckdns.aqueipo.arqsw.unit.hateoas.HateoasManagerTest
[ERROR] testLinks  Time elapsed: 0.023 s  <<< ERROR!
java.lang.RuntimeException: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for org.duckdns.aqueipo.arqsw:callejero::jar:1.0.0-SNAPSHOT
Caused by: io.quarkus.bootstrap.BootstrapException: Failed to create the application model for org.duckdns.aqueipo.arqsw:callejero::jar:1.0.0-SNAPSHOT
Caused by: io.quarkus.bootstrap.resolver.AppModelResolverException: Failed to resolve dependencies for org.duckdns.aqueipo.arqsw:callejero:jar:1.0.0-SNAPSHOT
Caused by: org.eclipse.aether.resolution.DependencyResolutionException: Failed to collect dependencies at io.quarkus:quarkus-resteasy:jar:1.4.2.Final
Caused by: org.eclipse.aether.collection.DependencyCollectionException: Failed to collect dependencies at io.quarkus:quarkus-resteasy:jar:1.4.2.Final
Caused by: org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for io.quarkus:quarkus-resteasy:jar:1.4.2.Final
Caused by: org.eclipse.aether.resolution.ArtifactResolutionException: Could not transfer artifact io.quarkus:quarkus-resteasy:pom:1.4.2.Final from/to central (https://<my_domain>/repository/maven-group/): Authentication failed for https://<my_domain>/repository/maven-group/io/quarkus/quarkus-resteasy/1.4.2.Final/quarkus-resteasy-1.4.2.Final.pom 401 Unauthorized
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact io.quarkus:quarkus-resteasy:pom:1.4.2.Final from/to central (https://<my_domain>/repository/maven-group/): Authentication failed for https://<my_domain>/repository/maven-group/io/quarkus/quarkus-resteasy/1.4.2.Final/quarkus-resteasy-1.4.2.Final.pom 401 Unauthorized
Caused by: org.apache.maven.wagon.authorization.AuthorizationException: Authentication failed for https://<my_domain>/repository/maven-group/io/quarkus/quarkus-resteasy/1.4.2.Final/quarkus-resteasy-1.4.2.Final.pom 401 Unauthorized

Это задание завершается ОК, когда gitlab-runner относится к типу исполнитель оболочки. Есть идеи ??

...