如何连接到 azure 工件源并使用 yaml azure 管道中的 gradle 发布 Maven 工件,我想在 azure 工件中发布我的工件,以便我的 Maven 中央依赖项存储在名为“GradleBinaries”的源中,并且 SNAPSHOT 存储在一个名为“CustomArtifacts”的不同提要...我没有setting.xml 文件...如果有人可以提供帮助,我将不胜感激
我尝试过执行官方文档中提到的方法,但没有成功
要在管道中使用Gradle发布maven包,可以参考以下步骤:
build.gradle
文件中,如下所示:plugins {
id 'java-library'
id "net.linguica.maven-settings" version "0.5"
id 'maven-publish'
}
build.gradle
和 repositories
容器中的 publishing.repositories
文件中。maven {
url 'https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/maven/v1'
name '<FEED_NAME>'
credentials {
username = "AzureDevOps"
password = System.getenv("SYSTEM_ACCESSTOKEN")
}
authentication {
basic(BasicAuthentication)
}
}
这是我的样本
build.gradle
供您参考:
plugins {
// Apply the java-library plugin for API and implementation separation.
id 'java-library'
id "net.linguica.maven-settings" version "0.5"
id 'maven-publish'
}
publishing {
publications {
myPublication(MavenPublication) {
groupId 'org.gradle.sample'
artifactId 'my-gradle-lib'
version '1.0.0'
}
}
// Repositories to publish artifacts
repositories {
maven {
url 'https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/maven/v1'
name '<FEED_NAME>'
credentials {
username = "AzureDevOps"
password = System.getenv("SYSTEM_ACCESSTOKEN")
}
authentication {
basic(BasicAuthentication)
}
}
}
}
repositories {
maven {
url 'https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/maven/v1'
name '<FEED_NAME>'
credentials {
username = "AzureDevOps"
password = System.getenv("SYSTEM_ACCESSTOKEN")
}
authentication {
basic(BasicAuthentication)
}
}
}
...
}
Gradle@3
发布您的包并通过环境变量 SYSTEM_ACCESSTOKEN
传递密码。trigger:
- none
pool:
vmImage: ubuntu-latest
steps:
- task: Gradle@3
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
gradleWrapperFile: 'gradlew'
tasks: 'publish'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
sonarQubeRunAnalysis: false
spotBugsAnalysis: false