【问题标题】:How to deploy Jenkins builds into a Maven repository on the local filesystem如何将 Jenkins 构建部署到本地文件系统上的 Maven 存储库中
【发布时间】:2012-04-15 13:11:36
【问题描述】:

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

【问题讨论】:

    标签: java maven build hudson jenkins


    【解决方案1】:

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

    与 Maven 2 不同,Maven 3 仅支持开箱即用的 http:、https: 和 文件:作为传输协议。使用其他传输协议,例如 scp:, 必须在 POM 中明确声明适当的货车 作为构建扩展。如果有问题的货车仅用于 部署到存储库,也可以将其声明为 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 路径以查看不同版本是否不冲突。

    【讨论】:

    • 嗯,这应该,但也不适合我。 Jenkins 的“部署 Maven Artifcats”构建后步骤似乎不支持此扩展。
    猜你喜欢
    • 2014-12-28
    • 1970-01-01
    • 2022-07-25
    • 1970-01-01
    • 2014-02-15
    • 2010-09-06
    • 2011-05-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多