【发布时间】:2018-01-09 15:41:49
【问题描述】:
我需要从 Jenkins 声明式管道将工件上传到 Nexus。有一个 Nexus plugin 我不能使用,因为它不允许发布 SNAPSHOT。因此我必须通过 Gradle 上传任务直接上传它们。问题是我从 Nexus 收到 401 错误代码,并且似乎没有将 nexus 用户和密码从管道传递到 ./gradlew upload 任务。
这是我当前的配置:
管道
withCredentials([usernamePassword(credentialsId: 'asdf23432-fe69-1234-2222-ffa65yteec2c', passwordVariable: 'NEXUS_PASSWORD', usernameVariable: 'NEXUS_USER')]) {
sh "./gradlew upload --debug"
}
Gradle:在下一节中,我尝试从 withCredentials 步骤访问 NEXUS_USER 和 NEXUS_PASSWORD 变量。
ext{
nexusUser = System.properties['NEXUS_USER']
nexusPassword = System.properties['NEXUS_PASSWORD']
}
uploadArchives {
repositories {
mavenDeployer {
snapshotRepository(url: 'http://somerepo'){
authentication(userName: nexusUser, password: nexusPassword)
}
}
}
}
【问题讨论】:
标签: jenkins gradle jenkins-pipeline nexus