12

I am using the M2 release plugin from within Jenkins which calls the maven-release-plugin 2.3.2 internally and while building throws this error : You don't have a SNAPSHOT project in the reactor projects list. Problem is , my projects poms do have their version as 1.0.0-SNAPSHOT. What am I missing ?

com.abc.def is the company parent POM , and I am just doing for mvn release for utils

<modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.abc</groupId>
        <artifactId>def</artifactId>
        <version>1.0.0</version>
    </parent>

    <groupId>com.abc.def</groupId>
    <artifactId>utils</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>utils</name>

And yes, I have done my basic Google + SO trawl and everywhere it points that my POMs should be having SNAPSHOT as the version , which is already there. Except that my company parent POM is not snapshot. Could that be the reason ?

Pulak Agrawal
  • 2,481
  • 4
  • 25
  • 49

5 Answers5

14

I had the same problem but these solutions didn't work. This blog post by Tomek Kaczanowski hit the nail on the head.

The cause often is that the Jenkins SVN strategy is set to "use svn update as much as possible" which does not clean up the build workspace between builds.

When you try to cut a release, Jenkins will update your pom and create some temporary files. If the release fails, these pom updates and temp files are not cleaned up. So then, when you fix the pom and try to rebuild, you get the You don't have a SNAPSHOT project in the reactor projects list error due to these funky workspace artifacts confusing Jenkins.

The solution is to change your Jenkins SVN strategy. Any of the following should work:

  • always check out a fresh copy
  • emulate clean checkout by first deleting unversioned/ignored files, then 'svn update'
  • use svn update as much as possible, with 'svn revert' before update

I'd also recommend you clear out your Jenkins workspace just to make sure you're starting fresh.

Marquee
  • 1,776
  • 20
  • 21
  • 2
    you are correct. At the time I posted the question, I was still learning the maven-Jenkins ropes, but found the same myself few days after that. Should have corrected my answer, but since you posted first, I have to give it you. Thanks for fixing this. – Pulak Agrawal Jul 17 '13 at 16:08
  • Could you specify what exactly needs to be cleaned? – Dusan Plavak Dec 12 '22 at 11:38
  • @DusanPlavak When I wrote this, there was a button on the jobs to delete the Job workspace. I don't use the old style jobs anymore and I don't see the button. But here's how you do it with the pipeline syntax: stage('Clean Workspace') { steps { deleteDir() } } – Marquee Jan 10 '23 at 06:13
5

Master pom doesn't need to be SNAPSHOT as well (at my company we have the same setup and it works OK). This part of utils pom is OK as far as I can tell, so maybe you're missing something else, like

<scm>
    <developerConnection>scm:${release-scm}</developerConnection>
</scm>

and of course the maven release plugin section in build definition in your POM ? (a long shot I know)

Pulak Agrawal
  • 2,481
  • 4
  • 25
  • 49
tohokami
  • 340
  • 1
  • 3
  • 9
  • The fact that I able to reach the stage where it throws the error `You don't have a SNAPSHOT project in the reactor projects list`, this means I have configured the the `` tag properly by reading this http://maven.apache.org/scm/plugins/usage.html , so not this is not the problem . And if I did not have the maven release plugin declared in the parent POM, I would hit an error saying `Unknown lifecycle phase mvn release` or something like that and not reached this stage – Pulak Agrawal Nov 23 '12 at 06:58
  • I've created a test project similar to what you have (master without snapshot, pom packaging) and I've put it through Jenkins v1.488 and m2 release plugin v0.9.1. Master is using release plugin v2.2.1 and scm plugin v1.5. I haven't been able to recreate the issue, aside from a very questionable scenario. Namely, the only time I get the same error is when pom is having a version that doesn't end with SNAPSHOT, e.g. 1.0.0-SNAPSHOT-suffix. Here it might happen since developers are branching for every issue (human error in version). Could you child modules be having this in version? – tohokami Nov 23 '12 at 09:24
  • Also, if you don't mind sending a cleaned up version of your pom's, I'd be glad to run them through Jenkins as see what happens. Or, I can clean up ours and send you if you like. – tohokami Nov 23 '12 at 09:25
  • hmm.. let me investigate further.. will try to find a bad version somehwere – Pulak Agrawal Nov 23 '12 at 09:50
  • This is what I did: I commented out the `..` in the `utils' POM and I progressed to another error which is access related; I need more testing but looks like I'll find the culprit as one of the child POMs playing with me.. will know for sure on Monday - TGIF :) – Pulak Agrawal Nov 23 '12 at 11:21
  • didn't work.. I have found the reason though. See my own answer. – Pulak Agrawal Nov 27 '12 at 11:00
  • 1
    Interesting! Usually deleting local m2 repo solved all such issues, and certainly didn't occur when artifact (master pom in your case) version was upped (which I suppose you did too). Well, glad you solved it :-) – tohokami Dec 01 '12 at 15:50
5

i sometimes found spelling problems with the term: "SNAPSHOT", which basically will also lead to the same error. like:

 1. SNAPSOT
 2. SNASHOT
 3. SHNAPSOT

;-) so it is worth to check this out upfront.

cool for fixing is to use on the parent pom:

versions:set
cschaefer
  • 1,654
  • 2
  • 12
  • 10
3

Actually the Jenkis's workspace contain old non SNAPSHOT versions of some modules. Try to wipout the workspace (=to clean and clear it), then do a release again, he will get the correction versions with the suffix -SNAPSHOT

2

I found the reason: The latest company Parent POM was not being picked up

  1. I had clean and -U both in the mvn argument list. Did not work
  2. Then I cleaned the ~/.m2 repository. Did not work

What worked is, in Jenkins

  1. Goto the Job config page
  2. Go to Build , click Advanced
  3. Check the box Use private Maven repository
  4. Select Local to the workspace. Save

I know this is one of those weird things Maven has a habit of doing for some reason. And as usual the errors are not informative/intuitive enough.

Pulak Agrawal
  • 2,481
  • 4
  • 25
  • 49