Skip to content
Permalink
Browse files

[FIXED JENKINS-16028] [FIXED JENKINS-18762] Adds EnvAction to hold CO…

…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 581c57e7068bca29cdbfcdb15419ac7d8e3b1fa4
Showing with 4 additions and 16 deletions.
  1. +4 −16 src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
@@ -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 = "**";
@@ -497,20 +499,6 @@ public void onRenamed(Item item, String oldName, String newName) {
}
}

// 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>();

0 comments on commit 581c57e

Please sign in to comment.
You can’t perform that action at this time.