Move functionality to common area

This commit is contained in:
Dan Hawkins 2019-04-28 14:50:31 +01:00
commit 8fecc6c320

View file

@ -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 = [:]