如何将Jenkins构建部署到本地文件系统上的Maven存储库中

时间:2012-04-01 18:09:07

标签: java maven build hudson jenkins

我想在我自己的目录中存储构建,我不想运行Sonatype Nexus或类似的东西。这可能吗?

我设置Jenkins将工件部署到我的Maven存储库并填写此URL

file:///home/tomas/.m2/repository

如果我尝试构建项目,我将得到此异常

Maven RedeployPublished use remote  maven settings from : /var/lib/jenkins/tools/mvn/conf/settings.xml
[INFO] Deployment in /home/tomas/.m2/repository (id=,uniqueVersion=true)
Deploying the main artifact wst-root-pom-1.0.pom
ERROR: Failed to deploy artifacts/metadata: No connector available to access repository  (/home/tomas/.m2/repository) of type default using the available factories WagonRepositoryConnectorFactory
org.apache.maven.artifact.deployer.ArtifactDeploymentException: Failed to deploy artifacts/metadata: No connector available to access repository  (/home/tomas/.m2/repository) of type default using the available factories WagonRepositoryConnectorFactory
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:141)
    at hudson.maven.reporters.MavenArtifactRecord.deploy(MavenArtifactRecord.java:182)
    at hudson.maven.RedeployPublisher.perform(RedeployPublisher.java:176)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:19)
    at hudson.model.AbstractBuild$AbstractRunner.perform(AbstractBuild.java:703)
    at hudson.model.AbstractBuild$AbstractRunner.performAllBuildSteps(AbstractBuild.java:678)
    at hudson.maven.MavenModuleSetBuild$RunnerImpl.post2(MavenModuleSetBuild.java:998)
    at hudson.model.AbstractBuild$AbstractRunner.post(AbstractBuild.java:625)
    at hudson.model.Run.run(Run.java:1435)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:481)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:238)
Caused by: org.sonatype.aether.deployment.DeploymentException: Failed to deploy artifacts/metadata: No connector available to access repository  (/home/tomas/.m2/repository) of type default using the available factories WagonRepositoryConnectorFactory
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:235)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:211)
    at org.sonatype.aether.impl.internal.DefaultRepositorySystem.deploy(DefaultRepositorySystem.java:443)
    at org.apache.maven.artifact.deployer.DefaultArtifactDeployer.deploy(DefaultArtifactDeployer.java:137)
    ... 11 more
Caused by: org.sonatype.aether.transfer.NoRepositoryConnectorException: No connector available to access repository  (/home/tomas/.m2/repository) of type default using the available factories WagonRepositoryConnectorFactory
    at org.sonatype.aether.impl.internal.DefaultRemoteRepositoryManager.getRepositoryConnector(DefaultRemoteRepositoryManager.java:400)
    at org.sonatype.aether.impl.internal.DefaultDeployer.deploy(DefaultDeployer.java:231)
    ... 14 more
[INFO] Deployment failed after 0,26 sec
Build step 'Deploy artifacts to Maven repository' changed build result to FAILURE
Finished: FAILURE

1 个答案:

答案 0 :(得分:3)

我记得那是maven 3兼容性问题。根据笔记:https://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html#Maven3.xCompatibilityNotes-TransportProtocols%2528Wagons%2529

  

与Maven 2不同,Maven 3支持开箱即用http:,https:和   file:作为传输协议。使用其他传输协议   scp :,必须在POM中明确声明相应的货车   作为构建扩展。如果有问题的货车仅用于   部署到存储库,它也可以声明为   Maven Deploy插件的依赖关系。

因此请确保您使用的是Maven 3,否则您必须下载自己的旅行车作为maven扩展。以下是使用Maven扩展的指南: http://maven.apache.org/guides/mini/guide-using-extensions.html

注意: Wagon 1.0-beta-3 +需要Maven 2.1.0或更高版本。对于Maven 2.0.10及更早版本,请使用Wagon 1.0-beta-2。

<project>
  ...
  <build>
    <extensions>
      <extension>
        <groupId>org.apache.maven.wagon</groupId>
         <artifactId>wagon-file</artifactId>
         <version>1.0-beta-3</version>
      </extension>
    </extensions>
  </build>
  ...
</project>

这应该可以解决您的问题。如果它不起作用,请仔细检查您的maven路径以查看不同版本是否不冲突。