Erstellte eine Gitlab CI-Pipeline für eine Java-App, die Abhängigkeiten von Maven und Nexus liest
Die Gitlab-Pipeline wurde für die Ausführung als Nexus-Benutzer mit Administratorrechten konfiguriert. Dies wurde viele Male überprüft.
Aber als die Wenn die Gitlab-Pipeline ausgeführt wird, erhalten wir die folgende Fehlermeldung:
Code: Select all
[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
Code: Select all
https://blog.sonatype.com/how-to-use-gitlab-ci-with-nexus
Code: Select all
org.apache.maven.plugins
maven-compiler-plugin
3.8.0
1.8
1.8
org.apache.maven.plugins
maven-surefire-plugin
2.22.1
org.sonatype.plugins
nexus-staging-maven-plugin
1.5.1
default-deploy
deploy
deploy
maven-snapshots
http://host:8081/repository/maven-snapshots
true
maven-snapshots
http://host:8081/repository/maven-snapshots
maven-releases
http://host:8081/repository/maven-releases
maven-snapshots
http://host:8081/repository/maven-snapshots
maven-releases
http://host:8081/repository/maven-releases
Code: Select all
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
maven- Schnappschüsse
[adminuser]
[adminpassword]
Jede Hilfe wird sehr geschätzt.
Danke