我正在尝试将一个测试项目公开到其存储库,但收到了403 FORBIDDEN. 可能是什么问题呢?
.gitlab-ci.yml:
image: maven:3.8.4-eclipse-temurin-11
deploy:
stage: deploy
script: mvn deploy -s ci_settings.xml
Run Code Online (Sandbox Code Playgroud)
ci_settings.xml:
<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">
<servers>
<server>
<id>gitlab-maven</id>
<configuration>
<httpHeaders>
<property>
<name>Job-Token</name>
<value>${CI_JOB_TOKEN}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
Run Code Online (Sandbox Code Playgroud)
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>my.group</groupId>
<artifactId>my-commons</artifactId>
<version>1.0.0</version>
<repositories>
<repository>
<id>gitlab-maven</id>
<url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitlab-maven</id>
<url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
</repository>
<snapshotRepository>
<id>gitlab-maven</id>
<url>${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/maven</url>
</snapshotRepository>
</distributionManagement>
</project>
Run Code Online (Sandbox Code Playgroud)
结果。
[信息]上传到gitlab-maven: https://my.company.com/api/v4/projects/295/packages/maven/com/example/my-test/1.0.0/my-commons-1.0.0 .pom
[错误] 无法在项目 my-commons 上执行目标 org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy):无法部署工件:无法传输工件 com.example:my- commons:jar:1.0.0 来自/到 gitlab-maven:https: //my.company.com/api/v4/projects/295/packages/maven/com/example/my-test/1.0.0授权失败 /my-commons-1.0.0.jar,状态:403 禁止 -> [帮助 1]
| 归档时间: |
|
| 查看次数: |
1453 次 |
| 最近记录: |