在settings.xml中使用dockerfile-maven-plugin的加密密码

时间:2018-02-05 01:29:58

标签: maven-plugin

我们正在使用来自spotify的dockerfile-maven-plugin。插件配置如下,后面还有settings.xml片段。注意到如果我们尝试使用加密密码和settings-security.xml中配置的主密码,则dockerfile-maven-plugin会失败。问题是dockerfile-maven-plugin是否允许我们使用加密密码。

Out-Host

设置-security.xml文件

> [pscustomobject] @{ one=1; two=2 } | Out-Host; [pscustomobject] @{ one=10; three=30 } 

one two
--- ---
  1   2



one three
--- -----
 10    30

的settings.xml

<plugin>
  <groupId>com.spotify</groupId>
  <artifactId>dockerfile-maven-plugin</artifactId>
  <version>1.3.6</version>
  <executions>
    <execution>
      <id>default</id>
      <goals>
        <goal>build</goal>
        <goal>push</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <repository>host:port/${project.artifactId}</repository>
    <tag>${project.version}</tag>
    <buildArgs>
      <EAR_FILE>${project.build.finalName}.ear</EAR_FILE>
    </buildArgs>
    <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
  </configuration>
</plugin>

3 个答案:

答案 0 :(得分:2)

我有同样的问题,我通过使用这个maven扩展解决了它:

<extension>
  <groupId>com.github.shyiko.servers-maven-extension</groupId>
  <artifactId>servers-maven-extension</artifactId>
  <version>1.3.0</version>
</extension>

我使用的参考:https://apexplained.wordpress.com/2015/08/08/password-encryption-in-the-liquibase-maven-plugin/

我的配置结果如下:
的settings.xml

<server>
        <id>hub.example.com</id>
        <username>myUsername</username>
        <password>{q6S7TmCyTP0H0q0IGOSsgnHSdbQlwXRcAF6h4Jvh/b0=}</password>
</server>

<强>的pom.xml

<build>
<extensions>
    <extension>
        <groupId>com.github.shyiko.servers-maven-extension</groupId>
        <artifactId>servers-maven-extension</artifactId>
        <version>1.3.0</version>
    </extension>
</extensions>

<plugins>
    <groupId>com.spotify</groupId>
    <artifactId>dockerfile-maven-plugin</artifactId>
    <version>${com.spotify.dockerfile-maven-plugin.version}</version>
    <configuration>
        <repository>hub.example.com/${project.artifactId}</repository>
        <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
        <buildArgs>
            <JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
        </buildArgs>
    </configuration>
</plugin>
</plugins>

答案 1 :(得分:2)

引用README.md (v1.4.3)

  

从1.4.3版开始,支持在Maven设置文件中使用加密密码。有关在settings.xmlread the documentation here中加密服务器密码的更多信息。

答案 2 :(得分:1)

我遇到了同样的问题/问题。基于https://github.com/spotify/dockerfile-maven/blob/master/plugin/src/main/java/com/spotify/plugin/dockerfile/MavenRegistryAuthSupplier.java#L50的代码和尝试错误练习,密码应该是开放式的

  return RegistryAuth.builder()
    .username(server.getUsername())
    .password(server.getPassword())
    .build();