在Jenkins管道中工件上传期间,有没有办法更改Nexus URL路径
我正试图使用Jenkins管道将工件上传到nexus中,整个管道在最后阶段结束。当工件没有被上传到nexus存储库时 举个例子: 是我现有的存储库,我正试图将工件上传到其中。但当我开始Jenkins管道构建时,我看到url达到: . 我很困惑上面的url中的“存储库”是从哪里来的 我试过多次编辑url,但仍然遇到同样的问题 已开始上载工件blt-server.war GroupId:null ArtifactId:blt服务器 分类器: 类型:战争 版本:0.0.1-SNAPSHOT 文件:blt-server.war 存储库:发布 下载: 上传: 完成10%(5.5 MB/55 MB) 完成20%(11MB/55MB) 完成30%(17 MB/55 MB) 40%已完成(22 MB/55 MB) 50%已完成(28MB/55MB) 60%已完成(33 MB/55 MB) 70%已完成(39MB/55MB) 80%已完成(44 MB/55 MB) 90%已完成(50MB/55MB) 100%完成(55 MB/55 MB) 未能部署项目:在版本()中找不到项目:blt服务器:war:0.0.1-20190906.152523-1 上载文件blt-server.war失败 我希望url应该是这样的: 上传war文件时,但它不是 以下是我的管道脚本:在Jenkins管道中工件上传期间,有没有办法更改Nexus URL路径,jenkins,deployment,jenkins-pipeline,nexus,artifacts,Jenkins,Deployment,Jenkins Pipeline,Nexus,Artifacts,我正试图使用Jenkins管道将工件上传到nexus中,整个管道在最后阶段结束。当工件没有被上传到nexus存储库时 举个例子: 是我现有的存储库,我正试图将工件上传到其中。但当我开始Jenkins管道构建时,我看到url达到: . 我很困惑上面的url中的“存储库”是从哪里来的 我试过多次编辑url,但仍然遇到同样的问题 已开始上载工件blt-server.war GroupId:null ArtifactId:blt服务器 分类器: 类型:战争 版本:0.0.1-SNAPSHOT 文件:bl
pipeline {
agent {
label "master"
}
tools {
maven "Maven-3.5.2"
}
environment {
NEXUS_VERSION = "nexus3"
NEXUS_PROTOCOL = "http"
NEXUS_URL = "localhost:8081/nexus/content/repositories"
NEXUS_REPOSITORIES = "releases"
NEXUS_CREDENTIAL_ID = "SonatypeREMNexus3"
CREDENTIALSID= "********confidential***"
}
stages {
stage("clone bitbucket") {
steps {
checkout(
[
$class: 'GitSCM',
branches: [[name: 'master']],
doGenerateSubmoduleConfigurations: false,
extensions: [
[$class: 'RelativeTargetDirectory', relativeTargetDir: 'build']
],
submoduleCfg: [],
userRemoteConfigs: [
[
credentialsId: '********confidential***',
url: 'ssh://git@bitbucket.confidential:7999/blt/blt-server.git'
]
]
]
)
}
}
stage('Build & Test') {
steps {
script {
withMaven(
options: [artifactsPublisher(disabled: true)],
jdk: 'JAVA-1.8.0_152',
maven: 'Maven-3.5.2') {
sh "mvn clean package -f build/pom.xml"
}
}
}
}
stage("publish to nexus") {
steps {
script {
pom = readMavenPom file: "build/pom.xml";
filesByGlob = findFiles(glob: "build/target/*.${pom.packaging}");
echo "${filesByGlob[0].name} ${filesByGlob[0].path} ${filesByGlob[0].directory} ${filesByGlob[0].length} ${filesByGlob[0].lastModified}"
artifactPath = filesByGlob[0].path;
artifactExists = fileExists artifactPath;
if(artifactExists) {
echo "*** File: ${artifactPath}, group: ${pom.groupId}, packaging: ${pom.packaging}, version: ${pom.version}"
nexusArtifactUploader(
nexusVersion: NEXUS_VERSION,
protocol: NEXUS_PROTOCOL,
nexusUrl: NEXUS_URL,
groupId: pom.groupId,
version: pom.version,
repository: NEXUS_REPOSITORIES,
credentialsId: NEXUS_CREDENTIAL_ID,
artifacts: [
[artifactId: pom.artifactId,
classifier: '',
file: artifactPath,
type: pom.packaging],
[artifactId: pom.artifactId,
classifier: '',
file: "build/pom.xml",
type: "pom"]
]
);
} else {
error "*** File: ${artifactPath}, could not be found";
}
}
}
}
}
}
问题在于:
NEXUS_VERSION = "nexus3"
NEXUS_PROTOCOL = "http"
NEXUS_URL = "localhost:8081/nexus/content/repositories"
指定的Nexus版本是Nexus 3,但URL遵循Nexus 2格式
Nexus3使用URL格式/repository/
,而Nexus2使用/content/repositories//
如果您使用的是Nexus 2,只需更新版本Nexus\u version=“Nexus 2”
如果在Nexus 3上:
localhost:8081/nexus/content/repositories
替换为localhost:8081/nexus
或localhost:8081
,如果适用于您的nexus存储库你也可以 为什么您的groupid为“空”?Maven将根据GAV上传到coords.com。您在Nexus中定义了什么存储库(以及什么类型的存储库)?如果没有提供您在管道中使用的示例代码以及您尝试编辑URL的位置,则很难判断问题所在。存储库URL可能已在生成代理上的项目
pom.xml
或~/.m2/settings.xml
中指定。如果您的项目不使用pom.xml
,则存储库URL甚至可以作为选项-Durl
作为mvn deploy
命令的一部分,或者如果您使用nexusArtifactUploader
,则可以将其指定为nexusUrl
。很多可能性@Dibakar Aditya感谢您的快速浏览。我已经上传了上面的管道代码。请结账。@I谢谢您的快速检查。关于“groupid”null,我不知道为什么它会显示为“null”,我验证了pom.xml,它是这样的:```org.springframework.boot-spring-boot-starter-parent 2.1.5.RELEASE```@nk07感谢分享更多详细信息。这使故障排除变得更容易。这是一个优秀而快速的解决方案!它工作得很好。。谢谢你@迪巴卡尔Aditya@nk07谢谢很高兴我能帮忙。您可以选择将其标记为已接受的答案,以便其他面临类似问题的人也会发现这一点很有帮助。我正在尝试禁用它,我需要文件名看起来像demo-0.0.1.war。我曾尝试使用uniqueVersion:false禁用它,但运气不佳。你能告诉我我犯了什么错误吗@Dibakar AdityaI恐怕,这个插件不支持非唯一版本。事实上,如果您希望使用mvn
进行部署,甚至在Maven 3中也删除了该支持。感谢您提供的信息。有没有从工件文件中删除时间戳的替代方法?目前我看到的所有文件名如下:父目录``demo-server-0.0.1-20190909.162347-1.war demo-server-0.0.1-20190909.162347-1.war.md5 demo-server-0.0.1-20190909.162347-1.war.sha1 demo-server-0.0.1-2019090909.162350-2.pom demo-server-0.0.0.0.1-201909.162350-2.pom```