Проблема Maven Nexus - авторизация не удалась для 403 Запрещено - PullRequest
0 голосов
/ 10 января 2020

Мы занимаемся этой проблемой уже несколько дней.

Создан конвейер CI Gitlab для Java приложения, которое считывает зависимости от Maven и Nexus

Конфигурирование конвейера gitlab настроено для работы как пользователь Nexus с правами администратора, это было проверено много раз.

Но, когда выполняется конвейер gitlab, мы получаем следующую ошибку:

[ERROR] Failed to execute goal on project hello-component: Could not resolve dependencies for project x.y.z:hello-component:jar:1.6-SNAPSHOT: Failed to collect dependencies at a.b:c:jar:4.5.1132100: Failed to read artifact descriptor for b:c:jar:4.5.1132100: Could not transfer artifact a.b:c:pom:4.5.1132100 from/to maven-snapshots (http://host:8081/repository/maven-snapshots): Authorization failed for http://host:8081/repository/maven-snapshots/a/b/c/4.5.1132100/nidp-4.5.1132100.pom 403 Forbidden -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project hello-component: Could not resolve dependencies for project x.y.z:hello-component:jar:1.6-SNAPSHOT: Failed to collect dependencies at a.b:c:jar:4.5.1132100

Я также использовал следующее руководство:

https://blog.sonatype.com/how-to-use-gitlab-ci-with-nexus

В моем POM указано следующее, переменные env сконфигурированы в ci / cd / settings / variable:

     <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.8.0</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.22.1</version>
                </plugin>
                <plugin>
                    <groupId>org.sonatype.plugins</groupId>
                    <artifactId>nexus-staging-maven-plugin</artifactId>
                    <version>1.5.1</version>
                    <executions>
                        <execution>
                            <id>default-deploy</id>
                            <phase>deploy</phase>
                            <goals>
                                <goal>deploy</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <serverId>maven-snapshots</serverId>
                        <nexusUrl>http://host:8081/repository/maven-snapshots</nexusUrl>
                        <skipStaging>true</skipStaging>
                    </configuration>
                </plugin>
            </plugins>
        </build>

<repositories>
        <repository>
            <id>maven-snapshots</id>
            <url>http://host:8081/repository/maven-snapshots</url>
        </repository>
        <repository>
            <id>maven-releases</id>
            <url>http://host:8081/repository/maven-releases</url>
        </repository>
        <!--repository>
            <id>nexus.local</id>
            <url>$HOME/.m2/repository</url>
        </repository-->
    </repositories>

    <distributionManagement>
        <snapshotRepository>
            <id>maven-snapshots</id>
            <url>http://host:8081/repository/maven-snapshots</url>
        </snapshotRepository>
        <repository>
            <id>maven-releases</id>
            <url>http://host:8081/repository/maven-releases</url>
        </repository>
    </distributionManagement>

Средство запуска Gitlab CI имеет следующее:

image: maven:3.3.9-jdk-8

variables:
  GIT_STRATEGY: clone
  MAVEN_CLI_OPTS: "-s /opt/apache-maven-3.6.3/conf/settings.xml --batch-mode"
  MAVEN_OPTS: "-Dmaven.repo.local=/home/gitlab-runner/.m2/repository"

cache:
  paths:
    - /home/gitlab-runner/.m2/repository/
    - target/

stages:
  - build

CodeBuild:
  stage: build
  script:
   - /opt/apache-maven-3.6.3/bin/mvn $MAVEN_CLI_OPTS -X clean package
  artifacts:
    name: “x—y-component"
    paths:
      - ./target/x—y-component.jar

Настройка. xml на сервере gitlab ci имеет следующую ссылку на пользователя nexus:

maven-snapshots [adminuser] [adminpassword]

Любая помощь будет наиболее ценной.

Спасибо

...