diff --git a/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java b/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java index 01755baa..a5d9c612 100644 --- a/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java +++ b/jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java @@ -906,7 +906,62 @@ public JenkinsServer renameJob(FolderJob folder, String oldJobName, String newJo return this; } - + /** + * Rename a folder job + * + * @param oldFolderJobName existing folderJob name. + * @param newFolderJobName The new folderJob name. + * @throws IOException In case of a failure. + */ + public JenkinsServer renameFolderJob(String oldFolderJobName, String newFolderJobName) + throws IOException { + return renameFolderJob(null, oldFolderJobName, newFolderJobName, false); + } + + /** + * Rename a folder job + * + * @param oldFolderJobName existing folderJob name. + * @param newFolderJobName The new folderJob name. + * @param crumbFlag true to add crumbIssuer + * false otherwise. + * @throws IOException In case of a failure. + */ + public JenkinsServer renameFolderJob(String oldFolderJobName, String newFolderJobName, + Boolean crumbFlag) throws IOException { + renameFolderJob(null, oldFolderJobName, newFolderJobName, crumbFlag); + return this; + } + + /** + * Rename a folder job + * + * @param folder {@link FolderJob} + * @param oldFolderJobName existing folderJob name. + * @param newFolderJobName The new folderJob name. + * @throws IOException In case of a failure. + */ + public JenkinsServer renameFolderJob(FolderJob folder, String oldFolderJobName, + String newFolderJobName) throws IOException { + return renameFolderJob(folder, oldFolderJobName, newFolderJobName, false); + } + + /** + * Rename a folder job + * + * @param folder {@link FolderJob} + * @param oldFolderJobName existing folderJob name. + * @param newFolderJobName The new folderJob name. + * @param crumbFlag true to add crumbIssuer + * false otherwise. + * @throws IOException In case of a failure. + */ + public JenkinsServer renameFolderJob(FolderJob folder, String oldFolderJobName, + String newFolderJobName, Boolean crumbFlag) throws IOException { + client.post(UrlUtils.toJobBaseUrl(folder, oldFolderJobName) + "/confirmRename?newName=" + + EncodingUtils.formParameter(newFolderJobName), crumbFlag); + return this; + } /** * Closes underlying resources.