[英]Maven-metadata.xml mismatch when deploying from Jenkins to Nexus
[英]Jenkins deploying artifacts to Artifactory. maven-metadata.xml shows incorrect version for release and does not show versions for snapshot
我是Jenkins和Artifactory的新手,無法解決此問題。 我正在使用Jenkins 2.32.1,Artifactory 4.14.0,Jenkins Artifactory插件2.9.0和Maven2。我正在使用Jenkins管道進行構建。
這是我的jenkinsfile
:
node('default') {
try{
def server = Artifactory.newServer url: 'https://artifactory.com/artifactory', credentialsId: 'MYCREADENTIALS'
def rtMaven = Artifactory.newMavenBuild()
stage('Checkout') {
checkout myProject
}
stage('Artifactory configuration') {
rtMaven.tool = 'Default'
rtMaven.resolver server: server, releaseRepo: 'my-repo-all', snapshotRepo: 'my-repo-all'
rtMaven.deployer server: server, releaseRepo: 'my-repo-local', snapshotRepo: 'my-repo-local'
}
stage('Clean') {
rtMaven.run pom: 'pom.xml', goals: 'clean '
}
stage('Install') {
def buildInfo = rtMaven.run pom: 'pom.xml', goals: 'install '
server.publishBuildInfo buildInfo
}
} catch (err) {
echo "Caught: $err"
currentBuild.result = 'FAILURE'
}
}
我的Artifactory倉庫如下所示:
這是快照版本的pom.xml
的片段:
<groupId>com.my.group</groupId>
<artifactId>my-project-local</artifactId>
<packaging>jar</packaging>
<version>11-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>my description</description>
這是mavan-metadata.xml
:
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>com.my.group</groupId>
<artifactId>my-project-local</artifactId>
<version>11-20170126.182450-1</version>
<versioning>
<latest>11-20170126.182450-1</latest>
<release>11-20170126.182450-1</release>
<versions>
<version>4</version>
<version>5</version>
<version>6</version>
<version>7</version>
<version>8</version>
<version>11-20170126.173903-1</version>
<version>11-20170126.182450-1</version>
</versions>
<lastUpdated>20170126192233</lastUpdated>
</versioning>
</metadata>
我的問題是, maven-metadata.xml
文件將快照版本列為其最新發行版本,並且某些東西(Artifactory?)無法識別11-20170126.182450-1
版本實際上是快照版本。
當此存儲庫在我的其他項目的pom.xml
中被列為依賴項時,這會產生問題。 當它嘗試從該存儲庫中獲取最新版本時,會錯誤地嘗試獲取快照版本(11 -...),而不是發行版本(8)。
先感謝您! 感謝您對這個問題的任何建議或見解。
@Tunaki在我的問題評論中回答了我的問題。 我在pom.xml中使用范圍來引用帖子中提到的存儲庫中的工件。 我改用確切的版本號,現在可以正常使用了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.