Jenkins Maven版本进入lib-snapshot存储库

时间:2019-05-10 13:51:51

标签: maven jenkins release snapshot maven-release-plugin

我正在设置使用Jenkins将Maven项目发布到工件的位置。我看到Maven发行版所做的一切都工作正常,例如增加pom版本,创建标签,但它没有上载到lib-release仓库,而是将其上载到lib-snapshot仓库。

我验证了我的settings.xml,发现它为快照和发行版回购使用了不同的ID。我还能检查什么来解决此问题?

这是我的settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--<settings.version>1.0.1</settings.version>-->
<!--<settings.region>IL</settings.region>-->
<!--<settings.type>server</settings.type>-->
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <servers>
    <server>
      <id>artifactory_server</id>
      <username>deploy_user</username>
      <password>xxxxxxxxxxxxxxxxxxx</password>
    </server>
  </servers>
  <profiles>
    <profile>
      <repositories>
        <repository>
          <snapshots />
          <releases>
            <enabled>false</enabled>
          </releases>
          <id>artifactory-snapshots</id>
          <name>libs-snapshot</name>
          <url>http://artifactory.example.com/artifactory/libs-snapshot</url>
        </repository>
        <repository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <id>artifactory-release</id>
          <name>libs-release</name>
          <url>http://artifactory.example.com/artifactory/libs-release</url>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
          <releases>
            <enabled>true</enabled>
          </releases>
          <id>central</id>
          <name>plugins-release</name>
          <url>http://artifactory.example.com/artifactory/plugins-release</url>
        </pluginRepository>
        <pluginRepository>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <releases>
            <enabled>false</enabled>
          </releases>
          <id>snapshots</id>
          <name>plugins-snapshot</name>
          <url>http://artifactory.example.com/artifactory/plugins-snapshot</url>
        </pluginRepository>
      </pluginRepositories>
      <id>artifactory</id>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>
</settings>

1 个答案:

答案 0 :(得分:0)

这完全取决于Maven和POM的定义。 默认情况下,每次Jenkins运行都会受到快照的威胁,但是您可以通过以下方式控制它们 具有

的存储库
<snapshots>
   <enabled>false</enabled>
</snapshots>

并使用maven-release-plugin https://maven.apache.org/maven-release/maven-release-plugin/examples/prepare-release.html