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

我想将构建版本存储在自己的目录中,并且我不想运行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

解决方法:

我记得这是一个Maven 3兼容性问题.根据说明:https://cwiki.apache.org/MAVEN/maven-3x-compatibility-notes.html#Maven3.xCompatibilityNotes-TransportProtocols%2528Wagons%2529

Unlike Maven 2, Maven 3 supports out of the box only http:, https: and
file: as transport protocols. To use other transport protocols like
scp:, the appropriate wagons have to be explicitly declared in the POM
as a build extension. If the wagon in question is only used for
deployment to a repository, it can alternatively be declared as a
dependency of the Maven Deploy Plugin.

因此,请确保您使用的是Maven 3,否则必须下载自己的Wagon作为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路径,以查看不同版本是否不冲突.

上一篇:git fatal: 拒绝合并无关的历史的错误解决


下一篇:在Quartus II中编译写好的VHDL文件总是出现fatal error的弹框,弹框内容为 Fatal Error: Access Violation at 0X047FC728Module···