error code 400 appears when deploying with release: perform

Error details

When deploying Release version jar to Nexus with maven-release-plugin The job failed with the following error:

[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]

It seems that the deployment of sources.jar has failed, but when I check Nexus, it has already been uploaded. .. .. Looking at the log, it looks like ** source.jar has been deployed twice **. When I stopped creating source.jar as a trial, the same phenomenon occurred in ** javadoc.jar **.

[INFO] [INFO] --- maven-deploy-plugin:2.8:deploy (default-deploy) @ test-lib ---
/* jar,Pom deployment omitted*/
[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 again.Deploying the jar*/ 
[INFO] Uploading: [NexusURL]/releases/com/sample/test-lib/1.0.0/test-lib-1.0.0-sources.jar
///An error occurs here

Error cause

Like a maven bug. As of November 2017, it has not been closed yet. https://issues.apache.org/jira/browse/MNG-5868 https://issues.apache.org/jira/browse/MNG-5939

If you execute mvn -Prelease-profile help: effective-pom and see the pom that actually works, execution is double-defined as follows. (In my pom, only the upper definition was described)

   <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>

Countermeasures

  1. Modify maven-source-plugin and maven-javadoc-plugin
  2. Reduce maven version to 3.2.1

Measure 1

As above, run mvn -Prelease-profile help: effective-pom to find the execution you didn't specify. Then add the id listed there to pom. (In my case, the id of source-plugin was attach-sources and the id of javadoc-plugin was 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>

result

With the method of Countermeasure 1, we were able to successfully release the Release version.

Recommended Posts

error code 400 appears when deploying with release: perform
Error when deploying EC2
Error encountered with notes when deploying docker on rails
Error when playing with java
DB error on deploying with Heroku
Error when building infrastructure with aws app
[Swift] Perform error handling with Optional <Wrapped> type
[Rails] Error resolution when generating tokens with PAYJP
When deploying to Heroku, OpenApp causes an error
[Swift] Perform error handling with do-catch statement (Part 3)
[Swift] Perform error handling with do-catch statement (Part 2)
Error deploying rails5 + Mysql to heroku with Docker-compose
[Swift] Perform error handling with do-catch statement (Part 1)
Error when installing pygame (Command "python setup.py egg_info" failed with error code 1 in / tmp / pip-build-yovQQX / pygame /)
Workaround for Bundler.require error when executing ruby with crontab
[Swift] Perform error processing with Result <Success, Failure> type
When I bcrypt with node + docker, I got an error