我尝试使用带有Visual Studio Team Services的SBT驱动项目,特别是Packages插件。
包插件有关于如何使其与Maven一起使用的明确说明,但是我还没有能够确定适应SBT指令的方法,因为它们似乎依赖于配置驱动的黑客攻击Maven HTTP接口。
我的具体说明是:
在
中的用户settings.xml中添加凭据<servers>
代码
<server>
<id>projectspace-visualstudio.com-java</id>
<configuration>
<httpHeaders>
<property>
<name>Authorization</name>
<!--Treat this auth token like a password. Do not share it with anyone, including Microsoft support. The generated token expires on or before 12/24/2017-->
<value>Basic dXNlci5uYW1lOjQ5ZmphMm1leUowZVhBZ09pSktWMVFpTENKaGJHY2lPaUpTVXpJMU5pSXNJbmcxZENJNkltOVBkbU42TlUxZk4zQXRTR3BKUzJ4R1dIbzVNM1ZmVmpCYWJ5SjkuZXlKdVlXMWxhV1FpT2lKak5qZGhORFZoWmkwME5UZ3lMVFpsTlRFdFltUXhNeTB6WTJRMk1HVTJPRGhpTmpjaUxDSnpZM0FpT2lKMmMyOHVaSEp2Y0Y5M2NtbDBaU0IyYzI4dWNHRmphMkZuYVc1blgzZHlhWFJsSWl3aVlYVnBJam9pWTJZM1l6ZGxaRGt0TXpVeE55MDBZalU1TFRrMk4yRXRaalZoWW1RNE16UTNaV1UySWl3aWMybGtJam9pWVdZek1XRXpOVEF0TXpBNVl5MDBNalF3TFdKbU1XRXRZelV4TURJek5HWXhPV0ppSWl3aWFYTnpJam9pWVhCd0xuWnpjM0J6TG5acGMzVmhiSE4wZFdScGJ5NWpiMjBpTENKaGRXUWlPaUpoY0hBdWRuTnpjSE11ZG1semRXRnNjMzFaR2x2TG1OdmJYeDJjMjg2WWpFME5tUTBZalF0TVRSaU55MDBOVE5qTFdJNU5qa3RZVEpoTXpsaFpEZGtNVGc0SWl3aWJtSm1Jam94TlRBMk16M016UTVMQ0psZUhBaU9qRTFNVFF4TkRNek5UQjkuQkJLY25Wa1dZbHYwTFJrZkVIQnpEY3loaFJodTFwTmhFNk51WTB5UEFDTDY4MktiRGVTRXNTUWFZSkJOcG82Y3Bnal9lZThBbkhqc1otUG1PYWY0aGtsVE1Dd3hwbDhuTXdSRzVYeGJWMTFFS1lTOFFhMTdvWFFGY1JIMl9JbG84MlJMMS1PWlAxXzExcEZ0TU1ST0tTVW85X0ttTGM3RzF2YWlJcXc5YkFrejEyemRGeUNobVJEWmFDdWFBV1NQaUU1VVRPaV9aMi1oS291UVBWd0E4N29oelpZMjU0X25fN0o3UFdnczUweXVOaXZRc3Q5Y1U5MGJPMWNZWHUyMmtLMEVyeC05ZlptMUlwWGRoQ1hkZm1aTDlxUWFSbnp5dW9QaGVFelJoZWd6bExNTjFSaVk1U0FwOENqR1FnR3NmWEZsNlNMTnNYYnhUOUd0YjVGRUJ3</value>
</property>
</httpHeaders>
</configuration>
</server>
注意:由于显而易见的原因,故意对实际分配的内容进行了故意加扰。强制的auth标头的内容是标准的Auth-Basic Base64用户名:密码组合。
他们进一步指示
将此项添加到
内的项目pom.xml中<repositories>
代码和<distributionManagement>
代码
<repository>
<id>projectspace-visualstudio.com-java</id>
<url>https://projectspace.pkgs.visualstudio.com/_packaging/java/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
我已尝试断开用户名和密码,将其分配到凭据条目并尝试发布到&#34; https://projectspace.pkgs.visualstudio.com/_packaging/java/maven/v1&#34;但它不可避免地会失败。
尽管我可以说,VSTS软件包系统并没有给Realm提供标准的HTTP Auth挑战,没有Realm SBT(或者它是Ivy?)从不尝试发送凭据,放弃。与此同时,Maven只是在第一次尝试时发送凭证。
有没有办法让SBT发送凭据,或者类似地附加强制标头? (或者我是否完全误解了这个问题?)
感谢。
答案 0 :(得分:5)
我想我在尝试向我的问题添加更多信息时偶然发现了解决方案。
在尝试故意使用CURL上传失败时,我在详细输出中发现:
< WWW-Authenticate: Bearer authorization_uri=https://login.windows.net/67dd666e-d00e-4f5f-9f71-76760f050c78
< WWW-Authenticate: Basic realm="https://pkgsprodscussu2.app.pkgs.visualstudio.com/"
< WWW-Authenticate: TFS-Federated
将我的领域改为https://pkgsprodscussu2.app.pkgs.visualstudio.com/
SBT突然能够发布。
万岁。不幸的是,似乎无法保证领域价值稳定,但至少它现在起作用了。
作为其他人的参考,这是我最终得到的解决方案:
publishTo in ThisBuild := Some("vsts" at "https://projectspace.pkgs.visualstudio.com/_packaging/java/maven/v1/")
credentials in ThisBuild += {
import java.nio.charset.StandardCharsets
import java.util.Base64
val decodedArray: Array[Byte] = Base64.getDecoder.decode(
"""dXNlci5uYW1lOjQ5ZmphMm1leUowZVhBZ09pSktWMVFpTENKaGJHY2lPaUpTVXpJMU5pSXNJbmcxZENJNkltOVBkbU42TlUxZk4zQXRTR3BKUzJ4R1dIbzVNM1ZmVmpCYWJ5SjkuZXlKdVlXMWxhV1FpT2lKak5qZGhORFZoWmkwME5UZ3lMVFpsTlRFdFltUXhNeTB6WTJRMk1HVTJPRGhpTmpjaUxDSnpZM0FpT2lKMmMyOHVaSEp2Y0Y5M2NtbDBaU0IyYzI4dWNHRmphMkZuYVc1blgzZHlhWFJsSWl3aVlYVnBJam9pWTJZM1l6ZGxaRGt0TXpVeE55MDBZalU1TFRrMk4yRXRaalZoWW1RNE16UTNaV1UySWl3aWMybGtJam9pWVdZek1XRXpOVEF0TXpBNVl5MDBNalF3TFdKbU1XRXRZelV4TURJek5HWXhPV0ppSWl3aWFYTnpJam9pWVhCd0xuWnpjM0J6TG5acGMzVmhiSE4wZFdScGJ5NWpiMjBpTENKaGRXUWlPaUpoY0hBdWRuTnpjSE11ZG1semRXRnNjMzFaR2x2TG1OdmJYeDJjMjg2WWpFME5tUTBZalF0TVRSaU55MDBOVE5qTFdJNU5qa3RZVEpoTXpsaFpEZGtNVGc0SWl3aWJtSm1Jam94TlRBMk16M016UTVMQ0psZUhBaU9qRTFNVFF4TkRNek5UQjkuQkJLY25Wa1dZbHYwTFJrZkVIQnpEY3loaFJodTFwTmhFNk51WTB5UEFDTDY4MktiRGVTRXNTUWFZSkJOcG82Y3Bnal9lZThBbkhqc1otUG1PYWY0aGtsVE1Dd3hwbDhuTXdSRzVYeGJWMTFFS1lTOFFhMTdvWFFGY1JIMl9JbG84MlJMMS1PWlAxXzExcEZ0TU1ST0tTVW85X0ttTGM3RzF2YWlJcXc5YkFrejEyemRGeUNobVJEWmFDdWFBV1NQaUU1VVRPaV9aMi1oS291UVBWd0E4N29oelpZMjU0X25fN0o3UFdnczUweXVOaXZRc3Q5Y1U5MGJPMWNZWHUyMmtLMEVyeC05ZlptMUlwWGRoQ1hkZm1aTDlxUWFSbnp5dW9QaGVFelJoZWd6bExNTjFSaVk1U0FwOENqR1FnR3NmWEZsNlNMTnNYYnhUOUd0YjVGRUJ3"""
)
val decodedString = new String(decodedArray, StandardCharsets.UTF_8)
print("decoded: ")
println(decodedString)
val Array(userName, passwd) = decodedString.split(":", 2)
Credentials(
realm = "https://pkgsprodscussu2.app.pkgs.visualstudio.com/",
host = "projectspace.pkgs.visualstudio.com",
userName = userName,
passwd = passwd
)
}
答案 1 :(得分:0)
对我来说,它是这样工作的:
您需要转到工件,选择供稿并打开“连接到供稿”。有打开的Gradle并生成密码,用户名将在此页面的Gradle设置中。然后在构建sbt中使用以下设置。
val azureArtifactory ="Azure artifactory" at "https://projectspace.pkgs.visualstudio.com/_packaging/java/maven/v1/"
val azureArtifactoryCreds = Credentials(
""https://projectspace.pkgs.visualstudio.com",
"projectspace.pkgs.visualstudio.com", USER_NAME,
PASSWORD)```
.settings(publishTo in ThisBuild := Some(azureArtifactory),
credentials += azureArtifactoryCreds)