Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Aug 9, 2022
1 parent 580528d commit b72da69
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/main/java/hudson/plugins/promoted_builds/CopyListener.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package hudson.plugins.promoted_builds;

import hudson.Extension;
import hudson.Util;
import hudson.model.Item;
import hudson.model.Job;
import hudson.model.listeners.ItemListener;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.StandardCopyOption;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -34,9 +37,11 @@ public boolean accept(File child) {
if (subdirs != null) {
prop = ((Job<?,?>)item).getProperty(JobPropertyImpl.class);
for (File subdir : subdirs) try {
Util.copyFile(new File(subdir, "config.xml"),
new File(prop.getRootDirFor(subdir.getName()), "config.xml"));
} catch (Exception e) {
Files.copy(
new File(subdir, "config.xml").toPath(),
new File(prop.getRootDirFor(subdir.getName()), "config.xml").toPath(),
StandardCopyOption.REPLACE_EXISTING);
} catch (InvalidPathException | IOException e) {
Logger.getLogger(CopyListener.class.getName()).log(Level.WARNING,
"Failed to copy/load promotion " + subdir + " into new job", e);
}
Expand Down

0 comments on commit b72da69

Please sign in to comment.