Navigation Menu

Skip to content

Commit

Permalink
[FIXED JENKINS-15977] ClassNotFound is maven plugin not installed
Browse files Browse the repository at this point in the history
Check for the maven plugin being installed before trying to see
if the project src is a maven project.
  • Loading branch information
cjo9900 committed Dec 7, 2012
1 parent 09a8ae9 commit 6cd2d83
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
Expand Up @@ -195,7 +195,8 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
// for backward compatibility, look up the copier as CopyMethod
Copier copier = Copier.from(Jenkins.getInstance().getExtensionList(CopyMethod.class).get(0)).clone();

if (src instanceof MavenModuleSetBuild) {
if (Hudson.getInstance().getPlugin("maven-plugin") != null && (src instanceof MavenModuleSetBuild) ) {

This comment has been minimized.

Copy link
@imod

imod Feb 4, 2014

Member

I think you also have to check whether the plugin is active, just because the plugin is installed, does not mean its classes are available...
Hudson.getInstance().getPlugin("maven-plugin").getWrapper().isEnabled()
beware of NPE...

This comment has been minimized.

Copy link
@ikedam

ikedam Feb 5, 2014

Member

Do you know how I can produce the case Hudson.getInstance().getPlugin("maven-plugin").getWrapper().isEnabled() is false?
I want to test the behavior in my environment.

This comment has been minimized.

Copy link
@imod

imod Feb 5, 2014

Member

just disable the plugin in the plugin manager (GUI)

This comment has been minimized.

Copy link
@ikedam

ikedam Feb 5, 2014

Member

I could not produce a problem in following steps:

  1. Disable Maven plugin (and did not restart Jenkins)
  2. Install Copy Artifact plugin
  3. Run a build with Copy Artifact

I tested with Jenkins 1.532.1.
Plugins can access classes of disabled plugins until Jenkins restarts, can't they?
(and after restarting, getPlugin("maven-plugin") return null)

This comment has been minimized.

Copy link
@imod

imod Feb 5, 2014

Member

hmm, I'm not 100% sure - but is an easy check and I would just add it anyway - that's also what I see in most places where people have implemented checks like this ...it will for sure not hurt :)

// use classes in the "maven-plugin" plugin as might not be installed
// Copy artifacts from the build (ArchiveArtifacts build step)
boolean ok = perform(src, build, expandedFilter, targetDir, baseTargetDir, copier, console);
// Copy artifacts from all modules of this Maven build (automatic archiving)
Expand Down Expand Up @@ -347,11 +348,13 @@ public FormValidation doCheckProjectName(
FormValidation result;
Item item = new JobResolver(anc.getParent(),value).job;
if (item != null)
result = item instanceof MavenModuleSet
? FormValidation.warning(Messages.CopyArtifact_MavenProject())
: (item instanceof MatrixProject
if (Hudson.getInstance().getPlugin("maven-plugin") != null && item instanceof MavenModuleSet) {
result = FormValidation.warning(Messages.CopyArtifact_MavenProject());
} else {
result = (item instanceof MatrixProject)
? FormValidation.warning(Messages.CopyArtifact_MatrixProject())
: FormValidation.ok());
: FormValidation.ok();
}
else if (value.indexOf('$') >= 0)
result = FormValidation.warning(Messages.CopyArtifact_ParameterizedName());
else
Expand Down

0 comments on commit 6cd2d83

Please sign in to comment.