From a571aabf8da53ed1c08dcc5f88b60745b7d160f2 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 18 Oct 2023 11:34:49 -0700 Subject: [PATCH] [JENKINS-69711] Promotion configuration is lost when creating a new job by copy (#263) --- .../java/hudson/plugins/promoted_builds/CopyListener.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/hudson/plugins/promoted_builds/CopyListener.java b/src/main/java/hudson/plugins/promoted_builds/CopyListener.java index 983a3139..c2e3c739 100644 --- a/src/main/java/hudson/plugins/promoted_builds/CopyListener.java +++ b/src/main/java/hudson/plugins/promoted_builds/CopyListener.java @@ -37,9 +37,11 @@ public boolean accept(File child) { if (subdirs != null) { prop = ((Job)item).getProperty(JobPropertyImpl.class); for (File subdir : subdirs) try { + File dest = prop.getRootDirFor(subdir.getName()); + Files.createDirectories(dest.toPath()); Files.copy( new File(subdir, "config.xml").toPath(), - new File(prop.getRootDirFor(subdir.getName()), "config.xml").toPath(), + new File(dest, "config.xml").toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (InvalidPathException | IOException e) { Logger.getLogger(CopyListener.class.getName()).log(Level.WARNING,