首页 > 解决方案 > 无法使用 Gradle 插件在 Jenkins 中获取类型为 DefaultGroovyMavenDeployer 的对象的未知属性

问题描述

我正在尝试在 Jenkins 中执行 gradle 构建脚本。这个脚本有一个这样的任务部分:

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: 'https://mynexus.com/repository/maven-releases/') {
               authentication(userName: nexusReleaseUser, password: nexusReleasePassword)
            }
            snapshotRepository(url: 'https://mynexus.com/repository/maven-snapshots/') {
                authentication(userName:nexusSnapshotsUser, password:nexusSnapshotsPassword)}
            }
        }
}

其中 nexusReleaseUser、nexusReleasePassword、nexusSnapshotsUser 和 nexusSnapshotsPassword 是 gradle.properties 中定义的属性。

该脚本在我的本地机器上完美运行,但在 Jenkins 中失败。

* What went wrong:
A problem occurred evaluating project ':XXXXXXX'.
 > Could not get unknown property 'nexusReleaseUser' for object of type
org.gradle.api.publication.maven.internal.deployer.DefaultGroovyMavenDeployer.

我将这些属性添加到 Jenkins Gradle 插件配置中,在 jenkins 控制台中我可以看到它们已定义:

gradle -PnexusSnapshotsPassword=XXXXX -PnexusSnapshotsUser=XXXX -PnexusReleaseUser=XXXX -PnexusReleasePassword=XXXX clean buildAll -b build.gradle

即使一个放一个:

println nexusReleaseUser 

完美地工作并打印分配给属性的值......但是当在 maven deployer 的身份验证部分使用属性时根本不工作

你能帮助我吗?

标签: mavenjenkinsgradlenexus

解决方案


推荐阅读