gpt4 book ai didi

maven - Jenkins Pipeline Maven Artifactory 插件无法从中央 Maven 存储库解析 Artifact

转载 作者:行者123 更新时间:2023-12-05 04:10:53 24 4
gpt4 key购买 nike

当使用 Jenkins Freestyle 项目时,我能够使用“Maven3-Artifactory Integration”成功运行 Maven 构建。

当尝试在管道中使用此功能时,我遇到了从中央 Maven 存储库解析 Artifact 的问题。我的印象是,当 Jenkins 在 artifactory 中找不到 Artifact 时,它应该回退到中央 maven 存储库,https://repo.maven.apache.org/maven2 , 寻找神器。不是这样吗?

def server = Artifactory.server SERVER_ID
def rtMaven = Artifactory.newMavenBuild()
rtMaven.resolver server: server, releaseRepo: 'my-release-local', snapshotRepo: 'my-snapshot-local'
rtMaven.deployer server: server, releaseRepo: 'my-release-local', snapshotRepo: 'my-snapshot-local'
rtMaven.deployer.artifactDeploymentPatterns.addInclude("").addExclude("")
rtMaven.deployer.deployArtifacts = false
rtMaven.tool = MAVEN_TOOL
def buildInfo = rtMaven.run pom: POM_FILE, goals: GOALS
server.publishBuildInfo buildInfo

从控制台输出来看,Jenkins 似乎强制构建只解析来自 Artifactory 而不是其他任何地方的 Artifact ,即使它看到了中央仓库。

[main] DEBUG org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener - [buildinfo] Resolved artifact: org.apache.maven.plugins:maven-clean-plugin:pom:2.5:build from: central (https://repo.maven.apache.org/maven2, releases) Context is: plugin
[main] DEBUG org.jfrog.build.extractor.maven.resolver.ResolutionHelper - [buildinfo] Properties file '/tmp/buildInfo6034012728922541318.properties' retrieved from 'System.getProperty(buildInfoConfig.propertiesFile)'
[main] DEBUG org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseResolversHelper - [buildinfo] Enforcing snapshot repository for resolution: mysnapshotartifactoryURL
[main] DEBUG org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseResolversHelper - [buildinfo] Enforcing repository authentication: username=myusername, password=*** for snapshot resolution repository
[main] DEBUG org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseResolversHelper - [buildinfo] Enforcing release repository for resolution: myreleaseartifactoryURL
[main] DEBUG org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseResolversHelper - [buildinfo] Enforcing repository authentication: username=myusername, password=*** for release resolution repository
[main] DEBUG org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseArtifactResolver - Verifying availability of /home/myusername/.m2/repository/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom from [artifactory-release (myreleaseartifactoryURL, releases), artifactory-snapshot (mysnapshotartifactoryURL, snapshots)]
[main] DEBUG org.jfrog.build.extractor.maven.resolver.ArtifactoryEclipseRepositoryListener - [buildinfo] Could not resolve artifact: org.apache.maven.plugins:maven-plugins:pom:22:build
[main] ERROR org.apache.maven.cli.MavenCli - Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not find artifact org.apache.maven.plugins:maven-plugins:pom:22 in artifactory-release (myreleaseartifactoryURL)-> [Help 1]
org.apache.maven.plugin.PluginResolutionException: Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5

最佳答案

我前段时间遇到了同样的问题。我不知道它是否适用于你。流程是我内存中的artifactory:

  1. 检查我们用于本地构建的 libs-release-local。这与 libs-release
  2. Virtual Repository Associations
  3. libs-release 是一个虚拟仓库。并且 libs-release 下的 Included Repositorieslibs-release-localma​​ven-central-custom
  4. Artifact 的解析和上传在 libs-release-local 中完成/从中完成。如果所需 Artifact 不可用,maven 将遵循 libs-release-local --> libs-release --> maven-central-custom

下面是我们如何在 jenkinsfile 中使用它:

// Obtain an Artifactory server instance, defined in Jenkins --> Manage:
def server = Artifactory.server 'localArtifactory'
def rtMaven
def buildInfo

// Artifactory Maven Build instance
rtMaven = Artifactory.newMavenBuild()


rtMaven.tool = 'localMaven'

//where the Maven build should download its dependencies from
rtMaven.resolver server: server, releaseRepo: 'libs-release' , snapshotRepo: 'libs-snapshot'

//define where our build artifacts should be deployed to. we define the Artifactory server and repositories on the 'rtMaven' instance
rtMaven.deployer server: server, releaseRepo: 'libs-release-local', snapshotRepo: 'libs-snapshot-local'


//disable pushing to artifactory, true if requered
rtMaven.deployer.deployArtifacts = false

//By default, all the build artifacts are deployed to Artifactory. So, let's make filter and deployArtifacts=true
rtMaven.deployer.artifactDeploymentPatterns.addInclude("*-common-*")

rtMaven.run pom: 'pom.xml', goals: 'clean package'
rtMaven.deployer.deployArtifacts buildInfo

enter image description here

enter image description here

关于maven - Jenkins Pipeline Maven Artifactory 插件无法从中央 Maven 存储库解析 Artifact ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43745880/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com