copy folder from one location to another location through jenkins.instance groovy script
Answeredplease suggest me a script for how to copy job folder to another location, I have tried below one, but it is not working due to copy method is available for the library
Archival_Path="${Archival_Path}"
Source_Path="${Source_Path}"
node
{
stage('Copy') {
def log = "$Source_Path"
def folderName = log.substring(log.lastIndexOf("/") + 1, log.length())
println "$folderName"
def Archival_Path_folder=Archival_Path+"/"+folderName
println ("$Archival_Path_folder = merged")
def jenkins = Jenkins.instance
def folder = jenkins.getItemByFullName(Archival_Path)
if (folder == null) {
println "ERROR: Folder '$Archival_Path' not found"
}
else {
println "Folder found $folder"
}
// Get the all Folders
jenkins.getAllItems().findAll { it.fullName == "${Source_Path}" }.each { folder1 ->
println("$folder1.fullName")
if (folder1.fullName == "$Archival_Path_folder") {
println "folder is already there in the same folder"
} else{
println "Moving '$folder1.name' to '$folder.name'"
Items.move(folder1, folder)
}
}
}
}
-
Hi Rameshmari,
The Jenkins Pipeline is a DSL for defining Continuous Delivery pipelines. It is not designed for maintenance tasks.
The feature that is designed for this task is the Jenkins Script Console.
0
Please sign in to leave a comment.
Comments
1 comment