1
我試圖發佈到Artifactory使用項目的Gradle包裝和憑據鍵入用戶的gradle.properties。使用Grail的gradlew和用戶的gradle.properties文件發佈到Artifactory
在我build.gradle
文件,我有以下的代碼片段發佈到Artifactory
:
artifactory {
contextUrl = "https://path.to/artifactory"
publish {
repository {
repoKey = 'plugins-release-local'
username = ${artifactory_user}
password = ${artifactory_password}
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
這裏是我的gradle.properties
文件的內容:
[email protected] ~/.gradle
$ cat gradle.properties
artifactory_user=xxx
artifactory_password=yyy
的用戶名和密碼硬編碼build.gradle
,這個作品:
./gradlew artifactoryPublish
在嘗試試圖通過CLI傳遞憑據從~/.gradle/gradle.properties
./gradlew artifactoryPublish
HTTP response code: 502. HTTP response message: Bad Gateway
讀:
./gradlew -Dartifactory_user=xxx -Dartifactory_password=yyy artifactoryPublish
HTTP response code: 401. HTTP response message: Unauthorized
更新#每@RaGe的build.gradle的1
更新:
artifactory {
contextUrl = "https://path/to/artifactory"
publish {
repository {
repoKey = 'plugins-release-local'
username = artifactory_user
password = artifactory_password
maven = true
}
defaults {
publications ('mavenJava')
}
}
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
結果:得到一個401而不是502的使用:
- ./gradlew artifactoryPublish
- ./gradlew -Dartifactory_user = XXX -Dartifactory_password = YYY artifactoryPublish
更新#2
Artifactory在通過Apache 2.2上的反向代理訪問的Tomcat8/Java8上運行。
更新#3
注到解決方案:在Cygwin下,確保編輯正確的gradle.properties,位於C:\用戶\ username.gradle \ gradle.properties
我一直在來回走,確認了我的gradle.properties文件中的憑據,並對我的build.gradle中的值進行了硬編碼。當我對這些值進行硬編碼時,它始終都能正常工作。否則,我得到了401. – TekiusFanatikus
你嘗試了我建議的語法嗎? – RaGe
是的,請參閱更新#1和#2 – TekiusFanatikus