Jenkins部署到本地maven存储库

Jenkins部署到本地maven存储库,maven,jenkins,Maven,Jenkins,我试图将我的工件部署到本地maven存储库中,但我一直遇到问题。我定义了一个Post-build操作,将我的工件部署到以下url:file:///home/nick/.m2/repository/但我一直收到以下生成失败消息: [JENKINS] Archiving /var/lib/jenkins/workspace/ouPerson/pom.xml to edu.oakland.ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.pom [JENKINS] Arch

我试图将我的工件部署到本地maven存储库中,但我一直遇到问题。我定义了一个
Post-build操作
,将我的工件部署到以下url:
file:///home/nick/.m2/repository/
但我一直收到以下生成失败消息:

[JENKINS] Archiving /var/lib/jenkins/workspace/ouPerson/pom.xml to edu.oakland.ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.pom
[JENKINS] Archiving /var/lib/jenkins/workspace/ouPerson/target/ouPerson-0.2.0.jar to edu.oakland.ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.jar
channel stopped
Maven RedeployPublisher use remote  maven settings from : /var/lib/jenkins/tools/hudson.tasks.Maven_MavenInstallation/_home_nick_bin_maven/conf/settings.xml
[INFO] Deployment in file:///home/nick/.m2/repository/ (id=ouPerson,uniqueVersion=true)
Deploying the main artifact ouPerson-0.2.0.jar
Uploading: file:///home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.jar
Uploading: file:///home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0/ouPerson-0.2.0.pom
ERROR: Failed to deploy artifacts: Could not transfer artifact edu.oakland.ouPerson:ouPerson:jar:0.2.0 from/to ouPerson (file:///home/nick/.m2/repository/): Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts: Could not transfer artifact edu.oakland.ouPerson:ouPerson:jar:0.2.0 from/to ouPerson (file:///home/nick/.m2/repository/): Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:143)
    at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:193)
    at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:176)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:756)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
    at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1040)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:669)
    at hudson.model.Run.execute(Run.java:1735)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:234)
Caused by: org.eclipse.aether.deployment.DeploymentException: Failed to deploy artifacts: Could not transfer artifact edu.oakland.ouPerson:ouPerson:jar:0.2.0 from/to ouPerson (file:///home/nick/.m2/repository/): Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:341)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:269)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:413)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:139)
    ... 11 more
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact edu.oakland.ouPerson:ouPerson:jar:0.2.0 from/to ouPerson (file:///home/nick/.m2/repository/): Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1016)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$6.wrap(WagonRepositoryConnector.java:1004)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:895)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector.put(WagonRepositoryConnector.java:522)
    at org.eclipse.aether.internal.impl.DefaultDeployer.deploy(DefaultDeployer.java:335)
    ... 14 more
Caused by: org.apache.maven.wagon.TransferFailedException: Specified destination directory cannot be created: /home/nick/.m2/repository/edu/oakland/ouPerson/ouPerson/0.2.0
    at org.apache.maven.wagon.AbstractWagon.createParentDirectories(AbstractWagon.java:264)
    at org.apache.maven.wagon.providers.file.FileWagon.fillOutputData(FileWagon.java:100)
    at org.apache.maven.wagon.StreamWagon.getOutputStream(StreamWagon.java:188)
    at org.apache.maven.wagon.StreamWagon.put(StreamWagon.java:159)
    at org.eclipse.aether.connector.wagon.WagonRepositoryConnector$PutTask.run(WagonRepositoryConnector.java:871)
    ... 16 more
[INFO] Deployment failed after 0.13 sec
Build step 'Deploy artifacts to Maven repository' changed build result to FAILURE
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: FAILURE

知道我可能遗漏了什么吗?

好的,我找到了它不起作用的原因。我最初是通过
apt get
安装maven的,但是在部署时遇到问题,我决定下载
war
文件,并将
war
放入
$TOMCAT_HOME/webapps
中,然后我就可以毫无问题地部署到本地maven存储库中。希望这能帮助那些有类似问题的人

试试看
mvn安装

这将把您的工件安装到本地maven repo
如果你和maven一起建立Jenkins的工作,你就有了maven的最高目标。将此添加到您的工作中,并设定目标
清洁安装

别忘了提前添加pom.xml

是否尝试将文件物理复制到.m2文件夹?这就是最终结果。我想让jenkins自动化这个过程。难道你不能使用
mvn deploy
?我可以使用
mvn deploy
,但我试图设置它,让jenkins自动化构建,然后将它部署到我的maven存储库中。不过,我还是能够让它按预期工作,请参见下面我的答案。