Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven modules which no longer exist in a reactor project appear in the Jenkins build report as "didn't run"

Tags:

I have a multi-module maven project which contains nested some other reactor submodules. As result I have a 3 level hierarchy of modules.

In the past I refactored the hierachy, moving some nested modules from one to another. I modified as well the names of some of the modules.

On Jenkins, the old modules - now unexistent - appear in the build report as "didn't run". When I do locally a maven install these modules don't appear in the reactor summary.

Is this behavior somehow expected? I mean, are there any setting in jenkins which makes the reactor runner remember old sub-modules?

The "Delete workspace before build starts" option is enabled.

like image 597
diegomtassis Avatar asked Sep 17 '13 14:09

diegomtassis


2 Answers

If, for some reason, Delete All Disabled Modules is not available, then you can run this Groovy script in Manage Jenkins -> Script Console (https://<JENKINS_URL>/script). Based upon a script I found on the Jenkins Jira and improved with feedback here on Stack Overflow.

import jenkins.model.Jenkins
import hudson.maven.MavenModuleSet
import hudson.model.Result

Jenkins.instance
    .getAllItems(Job.class)
    .findAll({ job -> job instanceof MavenModuleSet })
    .each {
  job ->
    build = job.getLastBuild()
    if (build && build.getResult() == Result.SUCCESS) {
      println("==> Processing job " + job.name)
      build.getModuleBuilds().each {
        module, build ->
          if (build.isEmpty()) {
            //module.delete()
            println("  --> Deleted module " + module.name)
          }
      }
    } else {
      println("Warning: Skipped job " + job.name + " because its last build failed.")
    }
}

return null

How to use:

  1. Run the script first without any edits (it's safe, really!).
  2. Go through the list of changes to check for unwanted deletes.
  3. Uncomment module.delete().
  4. Run the (edited) script again.

Side effect: any archived builds that still had that module in the past, will no longer have the deleted module. In my use case this was acceptable.

like image 162
Amedee Van Gasse Avatar answered Sep 26 '22 05:09

Amedee Van Gasse


Have you tried the action Delete All Disabled Modules available between Configure and Modules on the project page ?

like image 28
Jean-Philippe Briend Avatar answered Sep 22 '22 05:09

Jean-Philippe Briend