当前位置: 首页 > 知识库问答 >
问题:

在哪里为Artifactory发布指定存储库元素?

洪开诚
2023-03-14

我试图在Artifactory存储库中发布一个项目。这是一个依赖于我的主项目的项目,所以我想把pom、.jar和sources.jar放在artifactory存储库中。

settings.xml文件存储在maven目录中:

D:\...\...\maven\apache-maven-3.3.1\conf  

我已经使用以下maven命令标记了版本:

mvn clean release:prepare  

那么,如果我尝试:

mvn clean release:perform –Partifactory  

,我得到了错误:

[信息][错误]未能在项目上执行目标org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy(default-deploy).........:部署失败:distributionManagement元素内部的POM中或-DaltDeploymentRepository=ID::Layout::URL参数中未指定存储库元素

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0  http://maven.apache.org/xsd/settings-1.0.0.xsd">

<localRepository>D:\...\...\maven\repository</localRepository>

<profiles>  
<profile>  
  <repositories>  
    <repository>  
      <snapshots>  
        <enabled>false</enabled>  
      </snapshots>  
      <id>central</id>  
      <name>libs-release</name>  
      <url>http://x/artifactory/libs-release</url>  
    </repository>  
    <repository>  
      <snapshots />  
      <id>snapshots</id>  
      <name>libs-snapshot</name>  
      <url>http://x/artifactory/libs-snapshot</url>  
    </repository>  
  </repositories>  
  <pluginRepositories>  
    <pluginRepository>  
      <snapshots>  
        <enabled>false</enabled>  
      </snapshots>  
      <id>central</id>  
      <name>plugins-release</name>  
      <url>http://x/artifactory/plugins-release</url>  
    </pluginRepository>  
    <pluginRepository>  
      <snapshots />  
      <id>snapshots</id>  
      <name>plugins-snapshot</name>  
      <url>http://x/artifactory/plugins-snapshot</url>  
    </pluginRepository>  
  </pluginRepositories>  
  <id>artifactory</id>  
</profile>  
  </profiles>  
  <activeProfiles>  
   <activeProfile>artifactory</activeProfile>  
  </activeProfiles>  

</settings> 
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <parent>
        <groupId>....</groupId>
        <artifactId>my-parent</artifactId>
        <version>1.0.6</version>
        <relativePath />
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <groupId>....</groupId>
    <artifactId>myproject</artifactId>
    <packaging>jar</packaging>
    <version>1.9.6-SNAPSHOT</version>
    <name>myproject</name>
    <url>${wiki.url}</url>
    <scm>    <developerConnection>scm:svn:http://x/svn/main/y/Development/Components/trunk/myproject</developerConnection>
        <url>http://x/svn/main/y/Development/Components/trunk/myproject</url>
    </scm>
    <ciManagement>
        <system>${ciManagement.system}</system>
        <url>${ciManagement.url}/${project.artifactId}</url>        
    </ciManagement>

    <properties>       
    </properties>

    <dependencies>
        <! -  - my dependencies -  - >
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <inherited>false</inherited>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>   <tagBase>http://x/svn/main/y/Development/Components/tags</tagBase>
                </configuration>
            </plugin>
        </plugins>
    </build>

    </project>

The parent pom :  

<!-- language: lang-xml -->

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>....</groupId>
    <artifactId>my-parent</artifactId>
    <packaging>pom</packaging>
    <version>1.0.6</version>
    <name>my-parent</name>
    <url>${wiki.url}</url>
    <scm>
        <developerConnection>scm:svn:http://x/svn/main/y/Development/Components/tags/my-parent-1.0.6</developerConnection>
        <url>http://x/svn/main/y/Development/Components/tags/my-parent-1.0.6</url>
    </scm>
    <ciManagement>
        <system>${ciManagement.system}</system>
        <url>${ciManagement.url}/${project.artifactId}</url>        
    </ciManagement>
    <build> 
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <inherited>true</inherited>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-site-plugin</artifactId>
                <version>3.3</version>
            </plugin>

        </plugins>
    </build>

</project>

共有1个答案

桓风史
2023-03-14

两件事。您应该在POM中声明 节:

<project>
  ...
  <distributionManagement>
    <repository>
     <id>my-artifactory</id>
     <name>Artifactory Release Repo</name>
     <url>http://x/artifactory/libs-release</url>
    </repository>
    <snapshotRepository>
     <id>my-artifactory</id>
     <name>Artifactory Release Repo</name>
     <url>http://x/artifactory/libs-snapshot</url>
    </snapshotRepository>
  </distributionManagement>
</project>

标记必须与settings.xml中的项匹配,才能使凭据匹配:

<settings>
  ...
  <servers>
   <server>
    <id>my-artifactory</id>
    <username>bob</username>
    <password>secret</password>
   </server>
  </servers>
</settings>

这就是说,由于MVN release:prepare已经在VCS中标记了该版本,所以不需要剪切新的版本,但是我建议您将 部分添加到POM中。部署工件的一种方法是简单地从VC获取标记并执行MVN部署,如下所示:

svn co <the url to your tag>
mvn -DaltDeploymentRepository=my-artifactory::default::http://x/artifactory/libs-release deploy
 类似资料:
  • 它是否将其存储在缓存中?我有一个应用程序,但应用程序中没有任何地方。属性是提到的db详细信息。我可以通过邮递员存储数据和查询它。

  • 我有一个Jenkins的自由式构建,基于一个使用SBT的Scala项目。我正试图使用Jenkins艺术工厂插件将生成的工件发布到艺术工厂存储库,特别是托管在artifactoryonline.com.的存储库。然而,我正在努力寻找一个合理的配置。我倾向于怀疑我错过了什么,但我无计可施,我找到的留档似乎都没有详细介绍这个用例,我厌倦了浏览艺术工厂插件源代码。非常感谢任何帮助。 情况如下。我想: 使用

  • 问题内容: 我正在Eclipse中进行Java项目。我创建了一个名为“ Spring”的用户库,并向其中添加了所有的Spring jar。我的问题是,Eclipse在哪里存储该库?是否将所有jar文件复制到磁盘上某个新目录中?还是在某些配置文件中维护有关哪些jar属于用户库的信息? 问题答案: Eclipse不会复制用户库的任何内容,它只是具有特定于机器的绝对路径的容器。用户库定义存储在工作空间中

  • 问题内容: 我已经卸载了wamp服务器,现在我需要恢复数据库。我该如何做? 问题答案: 无论如何,您都可以知道: 感谢MySql论坛的Barry Galbraith http://forums.mysql.com/read.php?10,379153,379167#msg-379167

  • 问题内容: jenkins中的共享库文件在作业开始时加载,它存储在哪里?我正在尝试访问存储在共享库中的dockerfile,我需要在dockerbuild命令中提供的路径。有什么办法可以找出共享库文件在jenkins中的装载位置? 问题答案: 如果共享库是从SCM加载的,并且您的工作空间路径是,则将签出到或类似副本(如果该路径被另一个并发构建占用,则可能后缀数字)。 ,如果我理解正确,您是否不想在

  • 问题内容: 因此,我有了这种elasticsearch安装,可以在用logstash插入数​​据时使用kibana可视化它们。 conf文件中的所有内容均已注释,因此它使用的是相对于elasticsearch文件夹的默认文件夹。 这怎么可能? 但是,此命令将删除数据: 谢谢。 ps:忘了说我在窗户上 问题答案: 如果您在Linux上安装了ES,则默认数据文件夹位于(CentOS)或(Ubuntu)