5
votes

I have a Nexus 3 which I deploy some artifacts from Jenkins with "mvn deploy". I have A LOT of modules 500+. The build looks kind of like this:

mvn clean package -DskipTests -DskipITs -T C1

mvn install -DskipTests -DskipITs -T C1

mvn deploy --quiet -DskipTests -DskipITs -Dmaven.validate.skip=true -Dmaven.compile.skip=true -Dmaven.test.skip=true -Dmaven.package.skip=true -Dmaven.integration-test.skip=true -Dmaven.verify.skip=true -T C1

The problem is that from time to time my artifacts have a timestamp while the metadata has a different timestamp. 1 second difference usually.

This is what I see in nexus at https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/maven-metadata.xml

<?xml version="1.0" encoding="UTF-8"?>
<metadata modelVersion="1.1.0">
  <groupId>com.company</groupId>
  <artifactId>my-artifact</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <versioning>
    <snapshot>
      <timestamp>20170613.140447</timestamp>
      <buildNumber>1</buildNumber>
    </snapshot>
    <lastUpdated>20170613140447</lastUpdated>
    <snapshotVersions>
      <snapshotVersion>
        <extension>war</extension>
        <value>1.0.0-20170613.140447-1</value>
        <updated>20170613140447</updated>
      </snapshotVersion>
      <snapshotVersion>
        <extension>pom</extension>
        <value>1.0.0-20170613.140447-1</value>
        <updated>20170613140447</updated>
      </snapshotVersion>
    </snapshotVersions>
  </versioning>
</metadata>

Judging the maven-metadata.xml, the artifact URL should be this:

https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/my-artifact/1.0.0-20170613.140447-1.war

But it is not. Instead, the artifact is at this location:

https://mynexus.com/repository/snapshots/com/company/my-artifact/1.0.0-SNAPSHOT/my-artifact/1.0.0-20170613.140446-1.war

mvn --version OpenJDK 64-Bit Server VM Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-03T21:39:06+02:00) Maven home: /usr/local/apache-maven Java version: 1.8.0_131, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-openjdk-amd64/jre Default locale: en_US, platform encoding: UTF-8 OS name: "linux", version: "4.4.0-64-generic", arch: "amd64", family: "unix"

The version of maven-deploy-plugin is 2.8.2

What am I doing wrong? How can I fix this? Thank you!

1
Are you really run those above given steps? This can be reduced to mvn clean deploy -DskipTests -DskipITs -T C1 cause the install part is done as part of the life cycle ? Apart from that I don't really understand your problem?khmarbaise
My build takes forever. We have master jenkins and slave jenkins. The package phase can be safely done in parallel on any machine. If two jobs run the install step in parallel on the same machine they will mess up the ~/.m2/repository metadata so we use a jenkins lock for that. The deploy step can be done in parallel but it takes a lot of time so we do it as a separate step to decrease the time the install need the lock. If we had clean deploy we either messed up the local maven metadata or we hold the lock for more time than needed.ddreian
First never use the local cache (~/.m2/repository) with different maven builds that will not work nor has it ever been designed for it. Each job has to have it's own cache for running. Furthermore about what does takes forever means? How long minutes, hours? How many modules? How many tests?khmarbaise
If I use a separete ~/.m2/repository it does not help my problem. It takes I think ~10 minutes the build or more and 3 minutes install and another 3 deploy. I do not have corrupted metadata in maven's m2 repo, only in nexus. I debugged the maven plugin that generates this, it's the deploy step. I think the best solution is not to use the -SNAPSHOT suffix in the version.ddreian

1 Answers

5
votes

This is a bug in Maven 3.5.0 and and will be resolved whenever 3.5.1 is released.

The original bug-report targed the deploy-plugin (https://issues.apache.org/jira/browse/MDEPLOY-221) however it's an issue with maven core: https://issues.apache.org/jira/browse/MNG-6240.

We hit the same issue at my work and after some digging and searching on mavens issue tracker I found the above links. I would suggest downgrading while waiting for 3.5.1 to come out.