[英]Publish Jar into Azure Artifact using gradle error
我要做的是使用 Gradle 將 Jar 文件發布到 Azure DevOps 工件中,但我得到了這個錯誤消息:
FAILURE:構建失敗並出現異常。
出了什么問題:在根項目“Project1”中找不到任務“發布”。
嘗試:運行 gradle 任務以獲取可用任務列表。 使用 --stacktrace 選項運行以獲取堆棧跟蹤。 使用 --info 或 --debug 選項運行以獲得更多日志 output。 運行 --scan 以獲得完整的見解。
在https://help.gradle.org獲得更多幫助
1 秒內構建失敗
Build.gradle 文件是這樣的:
apply plugin: 'java'
apply plugin: 'maven-publish'
publishing {
publications {
myPublication(MavenPublication) {
groupId 'soft'
artifactId 'crypto-utils'
version '5.2.0'
artifact 'C:\Users\d\Desktop\Project1\crypto-utils-5.2.0.jar'
}
}
// Repositories *to* which Gradle can publish artifacts
repositories {
maven {
url 'https://pkgs.dev.azure.com/soft/pm/_packaging/myFeed/maven/v1'
credentials {
username "myFeed"
//The Azure DevOps Services build system will use the "SYSTEM_ACCESSTOKEN" to authenticate to Azure DevOps Services feeds
password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken
}
}
}
}
// Repositories *from* which Gradle can download dependencies; it's the same as above in this example
repositories {
maven {
url 'https://pkgs.dev.azure.com/soft/pm/_packaging/myFeed/maven/v1'
credentials {
username "myFeed"
//The Azure DevOps Services build system will use the "SYSTEM_ACCESSTOKEN" to authenticate to Azure DevOps Services feeds
password System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") != null ? System.getenv("AZURE_ARTIFACTS_ENV_ACCESS_TOKEN") : vstsMavenAccessToken
}
}
}
請提供任何幫助
該問題可能是由於在錯誤的路徑中使用 gradle 引起的。 您需要在與Build.gradle
文件相同的目錄中運行 gradle。
如果您使用 Azure DevOps 構建管道,則存儲庫的根目錄路徑為$(system.defaultworkingdirectory)
。
除此之外,您可以嘗試gradle clean build
而不是gradle build
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.