From 8fecc6c3200bb0643b33ac9b44b78f43b7545cc6 Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Sun, 28 Apr 2019 14:50:31 +0100 Subject: [PATCH] Move functionality to common area --- install/installhelper.groovy | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/install/installhelper.groovy b/install/installhelper.groovy index 1464e9d..32da99b 100644 --- a/install/installhelper.groovy +++ b/install/installhelper.groovy @@ -1,3 +1,27 @@ +import hudson.FilePath + +// Transfer file from intermediate position to final position; +// creating necessary folders on the way; +// deleting intermediate file +def copyToFinalPosition(String pathToIntermediate, String finalBaseFolder, String finalFilename) { + def channel = Jenkins.getInstance().getComputer(env['NODE_NAME']).getChannel() + + def String abs_exports_root_path = "${WORKSPACE}/${finalBaseFolder}" + def String abs_export_out = "${abs_exports_root_path}/${finalFilename}" + def export_filepath = new hudson.FilePath(channel, abs_export_out) + def export_out_folder = export_filepath.getParent() + def export_out_folder_string = export_out_folder.toString() + def export_out_file = export_filepath.getName() + + echo "Creating folder ${export_out_folder_string}" + export_out_folder.mkdirs() + + echo "Copying from ${pathToIntermediate} to ${abs_export_out}" + def intermediate_filepath = new hudson.FilePath(channel, pathToIntermediate) + intermediate_filepath.copyTo(export_filepath) + intermediate_filepath.delete() +} + // Given details about artifacts to import and details of installers to build, import artifacts that are required def Map artifactsImporter(meta, artifactDetails, installerDetails) { artifactFetched = [:]