Java 依赖关系托管在GitLab';在管道作业期间未找到s maven存储库

Java 依赖关系托管在GitLab';在管道作业期间未找到s maven存储库,java,maven,gradle,continuous-integration,gitlab,Java,Maven,Gradle,Continuous Integration,Gitlab,我遇到了一个非常奇怪的问题。当我在我的计算机上构建插件时,一切都很好。但是,当插件在GitLab的管道中构建时,构建失败,表示未找到依赖项 Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find any matches for fr.group:theplugin:5.0.+ as no versions of fr.group:theplugin are available. S

我遇到了一个非常奇怪的问题。当我在我的计算机上构建插件时,一切都很好。但是,当插件在GitLab的管道中构建时,构建失败,表示未找到依赖项

Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find any matches for fr.group:theplugin:5.0.+ as no versions of fr.group:theplugin are available.
Searched in the following locations:
  - https://gitlab.com/api/v4/groups/GROUP-ID/-/packages/maven/fr/group/theplugin/maven-metadata.xml
我正在使用GitLab的maven存储库(PackageRegistry)来托管我自己的minecraft插件的人工制品。找不到依赖项托管在包注册表中。我已尝试删除所有gradle缓存并在计算机上重新构建。已按预期下载依赖项。因此,我要说的是,人工制品可以在包注册表中使用

我安装的gradle版本与包装器(gradle 6.5.1)相同。我也试着在我的电脑上运行包装器以防万一,它也可以正常工作

这是我的
构建。gradle

// Build plugins
plugins {
    id 'maven-publish'
    id 'java'
} 

// Upstream Maven repositories
repositories {
    mavenCentral()
    maven {//Dependencies on the Gitlab's group
        url "https://gitlab.com/api/v4/groups/GROUP-ID/-/packages/maven"
        name "GitLab"
        credentials(HttpHeaderCredentials) {
            name = 'Private-Token'
            value = gitLabPrivateToken
        }
        authentication {
            header(HttpHeaderAuthentication)
        }
    }
}

group = 'fr.mygroup'
version = 1.0.0

dependencies {
    compileOnly group: 'fr.group', name:'theplugin', version: '5.0.+', transitive: false
}


compileJava {
    sourceCompatibility = '1.8'
    options.encoding = 'UTF-8'
}


// Maven publish
publishing {
    publications {
        mavenJava(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            url "https://gitlab.com/api/v4/projects/PROJECT-ID/packages/maven"
            credentials(HttpHeaderCredentials) {
                name = "Private-Token"
                value = gitLabPrivateToken
            }
            authentication {
                header(HttpHeaderAuthentication)
            }
        }
    }
}
当然,我已经在我的real
build.gradle
中替换了
GROUP-ID
PROJECT-ID

这是我的.gitlab-ci.yml:

image: java:8

before_script:
    - chmod +x gradlew
    
stages:
  - build
  - test
  - publish

# Build stage
build:
  only:
    - tags
  tags:
    - docker
  stage: build
  script:
    - ./gradlew -g /cache/.gradle clean assemble -PgitLabPrivateToken=$CI_CUSTOM_TOKEN
  allow_failure: false

# Use the generated build output to run the tests.
test:
  only:
    - tags
  tags:
    - docker
  stage: test
  script:
    - ./gradlew -g /cache/.gradle check -PgitLabPrivateToken=$CI_CUSTOM_TOKEN

# Publish the artifact to GitLab
publish:
  only:
    - tags
  tags:
    - docker
  stage: publish
  script:
    - ./gradlew -g /cache/.gradle clean publish -PgitLabPrivateToken=$CI_CUSTOM_TOKEN
CI_CUSTOM_TOKEN
环境变量包含一个带有GitLab帐户作用域api的个人访问令牌,该帐户至少是GitLab组中的维护者(可能是所有者,我不记得了)

我尝试在witch中创建一个新的GitLab组,我克隆了我尝试构建的插件,我创建了相同的
CI\u CUSTOM\u TOKEN
environment变量,然后运行了一个管道,它完美地工作了

请让我知道,如果有什么不清楚或如果你需要更多的信息

谢谢你的阅读和帮助(我希望)


祝你今天愉快

问题是在
CI\u CUSTOM\u令牌
environment变量中选中了选项Protect变量。在consequences中,变量未传递到由未受保护的标记触发的管道。奇怪的是,我本应该有权限错误之类的,但它只是说找不到依赖项

不管怎么说,我取消了选择,现在它的完美工作