0

我有一个设置了一些服务器的 settings.xml 文件:

<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">

 ...
  <servers>

    <server>
      <id>server1</id>
      <username>user1</username>
      <!-- encrypted like https://maven.apache.org/guides/mini/guide-encryption.html  -->
      <password>{xxxxx}</password>
    </server>

    <server>
      <id>server2</id>
      <username>user2</username>
      <!-- encrypted like https://maven.apache.org/guides/mini/guide-encryption.html  -->
      <password>{xxxxx}</password>
    </server>

    <server>
      <id>svn</id>
      <username>userSVN</username>
      <!-- encrypted like https://maven.apache.org/guides/mini/guide-encryption.html  -->
      <password>{xxxxx}</password>
    </server>

  </servers>
...

我在这里读到,无法为 scm 插件设置特定服务器,并且您必须在 pom.xml 中添加一个属性

  <project>
   ...
    <properties>
      <project.scm.id>my-scm-server<project.scm.id>
    </properties>
  </project>

这是我的 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.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>2.0.0.M7</version>
  </parent>

  <groupId>org.test</groupId>
  <artifactId>test</artifactId>
  <version>1.0-SNAPSHOT</version>

  <properties>
    <svnRoot>xxx</svnRoot>
    <projectSvnPath>xxx</projectSvnPath>
    <svnRootUrl>https://xxx</svnRootUrl>
    <scmRoot>scm:svn:${svnRootUrl}</scmRoot>
    <project.scm.id>svn</project.scm.id>
  </properties>

  <scm>
    <connection>${scmRoot}${svnRoot}/trunk/${projectSvnPath}</connection>
    <developerConnection>${scmRoot}${svnRoot}/trunk/${projectSvnPath}</developerConnection>
  </scm>

  <build>
      <plugins>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.1</version>
          <dependencies>
            <dependency>
              <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
              <artifactId>maven-scm-provider-svnjava</artifactId>
              <version>1.10.1</version>
            </dependency>
            <dependency>
              <groupId>org.tmatesoft.svnkit</groupId>
              <artifactId>svnkit</artifactId>
              <version>1.8.7</version>
            </dependency>
          </dependencies>
          <configuration>
            <tagBase>${svnRootUrl}${svnRoot}/tags/${projectSvnPath}</tagBase>
            <branchBase>${svnRootUrl}${svnRoot}/branches/${projectSvnPath}</branchBase>
            <scmCommentPrefix>[maven-release-plugin]</scmCommentPrefix>
            <svn>javasvn</svn>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-scm-plugin</artifactId>
          <version>1.9</version>
          <dependencies>
            <dependency>
              <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
              <artifactId>maven-scm-provider-svnjava</artifactId>
              <version>1.10.1</version>
            </dependency>
            <dependency>
              <groupId>org.tmatesoft.svnkit</groupId>
              <artifactId>svnkit</artifactId>
              <version>1.8.7</version>
            </dependency>
          </dependencies>
          <configuration>
            <connectionType>connection</connectionType>
            <providerImplementations>
              <svn>javasvn</svn>
            </providerImplementations>
            <message>Maven commit</message>
          </configuration>
        </plugin>
      </plugins>
    </build>


  <profiles>
    <profile>
      <id>commit-pom</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-scm-plugin</artifactId>
            <executions>
              <execution>
                <phase>validate</phase>
                <goals>
                  <goal>checkin</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <includes>pom.xml</includes>
              <message>commit with profile commit-pom</message>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

  </profiles>
</project>

我尝试运行 mvn versions:update-parent 并且我的构建失败了

svn: E170001: ' https://xxx:443 Subversion Repository 'xxx'需要验证

这是Maven命令:

/bin/apache-maven-3.2.5/bin/mvn clean versions:update-parent -DallowSnapshots=true validate -Pcommit-pom -B -U --settings ../settings-maven/null_settings.xml --global-settings ../settings-maven/full-settings.xml

我尝试使用未加密的密码,但它也不起作用......

谢谢你的帮助!

4

1 回答 1

3

答案在这个页面上

在 settings.xml 通过服务器条目,使用连接 URL 中的主机名作为服务器 ID

如果我的 SVN 服务器 URL 是“ https://myserver.com ”,则 settings.xml 中的服务器 ID 必须是“myserver.com”

于 2018-01-10T10:22:39.127 回答