LoginSignup
0
0

More than 5 years have passed since last update.

release:performによるデプロイでエラーコード400が出る

Last updated at Posted at 2017-11-02

エラー詳細

maven-release-pluginでReleaseバージョンのjarをNexusにデプロイした際に、
以下のようなエラーでジョブが失敗した。

[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] BUILD FAILURE
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Total time: 10.235 s
[INFO] [INFO] Finished at: 2017-11-01T18:38:53+09:00
[INFO] [INFO] Final Memory: 32M/578M
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8:deploy
 (default-deploy) on project test-lib: Failed to deploy artifacts: Could not transfer artifact
 com.sample:test-lib:jar:sources:1.0.0 from/to nexus-releases ([NexusURL]/releases): 
Failed to transfer file: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar.
 Return code is: 400, ReasonPhrase: Bad Request. -> [Help 1]

sources.jarのデプロイに失敗しているようだが、Nexusを確認すると既にアップロード済。。。
ログを見てみると、source.jarのデプロイが二回行われているように見える。
試しにsource.jarの作成を止めてみたところ、javadoc.jarでも同様の現象が発生した。

[INFO] [INFO] --- maven-deploy-plugin:2.8:deploy (default-deploy) @ test-lib ---
/* jar,pomのデプロイは省略 */
[INFO] Uploading: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar
[INFO] Uploaded: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar 
[INFO] Uploading: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-javadoc.jar
[INFO] Uploaded: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-javadoc.jar
/* もう一度source.jarをデプロイしている */ 
[INFO] Uploading: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar
/// ここでエラー発生

エラー原因

mavenのバグのよう。2017/11現在まだクローズされていない。
https://issues.apache.org/jira/browse/MNG-5868
https://issues.apache.org/jira/browse/MNG-5939

mvn -Prelease-profile help:effective-pom を実行して実際に動作するpomを見ると、以下のようにexecutionが二重定義されている。(自分のpomでは上の方の定義のみ記載していた)

   <plugin>
      <artifactId>maven-source-plugin</artifactId>
      <version>3.0.1</version>
      <executions>
        <execution>
          <phase>install</phase>
          <goals>
            <goal>jar</goal>
          </goals>
        </execution>
        <execution>
          <id>attach-sources</id>
          <goals>
            <goal>jar</goal>
          </goals>
        </execution>
      </executions>
    </plugin>

対策

  1. maven-source-plugin, maven-javadoc-pluginに手を加える
  2. mavenのバージョンを3.2.1に下げる

対策1

上記の通りに、mvn -Prelease-profile help:effective-pom を実行して、自分が指定していないexecutionを見つける。
そして、そこに記載されているidをpomに加える。
(自分の場合は、source-pluginのidはattach-sources, javadoc-pluginのidはattach-javadocsだった)

pom.xml
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>3.0.1</version>
    <executions>
        <execution>
            <id>attach-sources</id>
            <phase>install</phase>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-javadoc-plugin</artifactId>
    <version>2.10.4</version>
    <executions>
        <execution>
            <id>attach-javadocs</id>
            <phase>install</phase>
            <goals>
                <goal>jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

結果

対策1の方式で無事にReleaseバージョンでのリリースができた。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0