Skip to content

Commit

Permalink
[FIXED JENKINS-16028] [FIXED JENKINS-18762] Adds EnvAction to hold CO…
Browse files Browse the repository at this point in the history
…PYARTIFACT_BUILD_NUMBER_XXX when it's needed. It was added when a build starts and the build has copyartifact, which doesn't work for maven-project and copyartifacts wrapped in other builders.
  • Loading branch information
ikedam committed Oct 1, 2014
1 parent 6ccfac8 commit 581c57e
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
Expand Up @@ -289,9 +289,11 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
}
// Add info about the selected build into the environment
EnvAction envData = build.getAction(EnvAction.class);
if (envData != null) {
envData.add(getItemGroup(build), expandedProject, src.getNumber());
if (envData == null) {
envData = new EnvAction();
build.addAction(envData);
}
envData.add(getItemGroup(build), expandedProject, src.getNumber());
if (target.length() > 0) targetDir = new FilePath(targetDir, env.expand(target));
expandedFilter = env.expand(filter);
if (expandedFilter.trim().length() == 0) expandedFilter = "**";
Expand Down Expand Up @@ -497,20 +499,6 @@ private static List<CopyArtifact> getCopiers(AbstractProject<?,?> project) throw
}
}

// Listen for new builds and add EnvAction in any that use CopyArtifact build step
@Extension
public static final class CopyArtifactRunListener extends RunListener<Build> {
public CopyArtifactRunListener() {
super(Build.class);
}

@Override
public void onStarted(Build r, TaskListener listener) {
if (((Build<?,?>)r).getProject().getBuildersList().get(CopyArtifact.class) != null)
r.addAction(new EnvAction());
}
}

private static class EnvAction implements EnvironmentContributingAction {
// Decided not to record this data in build.xml, so marked transient:
private transient Map<String,String> data = new HashMap<String,String>();
Expand Down

0 comments on commit 581c57e

Please sign in to comment.