【问题标题】:Using Jenkins to publish tar.gz to Nexus使用 Jenkins 将 tar.gz 发布到 Nexus
【发布时间】:2016-01-13 04:03:34
【问题描述】:

这是我要解决的问题:

  1. 从 Github 签出代码到本地目录 D
  2. 在目录 D 中运行配置命令
  3. 为目录创建一个 tar.gz
  4. 将 taz.gz 文件上传到 Nexus

我被困在第 3 步: - 我可以在 Maven pom.xml 文件中指定版本,但是有没有办法在每次运行 Jenkins 时自动创建构建版本? - 如果我在 pom.xml 文件中指定 tar.gz,我会得到:未知包装:gz @ 第 6 行,第 13 列

如果我在包装内指定jar,则没有错误,并且文件成功上传到Nexus。

任何建议都会有所帮助,谢谢!

==

按照建议,我正在使用 Assembly 插件,但仍然无法为 Directory RE 创建 tar.gz

这是我的 pom.xml:

<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.o$
<modelVersion>4.0.0</modelVersion>
<groupId>Auc</groupId>
<artifactId>RE</artifactId>
<version>1.0.0.112</version>
<!-- <packaging>tgz</packaging> -->
<name>RE Repository</name>
<url>http://nexus1.ccorp.com/nexus</url>
<build>
<plugins>
  <plugin>
     <artifactId>maven-assembly-plugin</artifactId>
     <version>2.6</version>
     <executions>
       <execution>
         <configuration>
           <descriptors>
             <descriptor>format.xml</descriptor>
           </descriptors>
         </configuration>
       </execution>
     </executions>
   </plugin>
 </plugins>
</build>
</project>

这是我的 format.xml 文件,RE 目录是我签出代码并想为其创建 tar.gz 的位置

<assembly
    xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
    <id>bundle</id>
    <formats>
       <format>tar.gz</format>
    </formats>
    <moduleSets>
            <moduleSet>
                    <sources>
                            <fileSets>
                                    <fileSet>
                                            <directory>/var/lib/jenkins/jobs/nightly_build/workspace/RE</directory>
                                    </fileSet>
                            </fileSets>
                    </sources>
            </moduleSet>
    </moduleSets>
    <includeBaseDirectory>false</includeBaseDirectory>

【问题讨论】:

标签: maven jenkins nexus


【解决方案1】:

这是我们最终的结果:

 mvn deploy:deploy-file -DgroupId=Home -DartifactId=RE -Dversion=0.0.0.1-SNAPSHOT -Dpackaging=tar.gz -DrepositoryId=Auc -Durl=http://nexus1.ccorp.com/nexus/content/repositories/snapshots -Dfile=RE-0.0.0.1-SNAPSHOT.tar.gz

确保 -DrepositoryId=Auc,Auc 是您在 setting.xml 中设置的部署 ID

<server>
  <id>Auc</id>
  <username>deployment</username>
  <password>deployment123</password>
</server>

【讨论】:

    【解决方案2】:

    您必须使用 Maven Assembly Plugin 创建 tar.gz,然后您可以像往常一样使用

    部署它
    mvn clean deploy
    

    以及 Jenkins 上可用的正确 settings.xml 以及部署所需的凭据。

    【讨论】:

      猜你喜欢
      • 2017-09-18
      • 2014-05-19
      • 1970-01-01
      • 2018-06-03
      • 2020-10-19
      • 2017-05-11
      • 2018-05-28
      • 2015-03-26
      • 1970-01-01
      相关资源
      最近更新 更多