Skip to content

Commit

Permalink
Fixed #169 Added crumbFlag to renameJob
Browse files Browse the repository at this point in the history
 o Enhanced API to have renameJob with and without crumbFlag
   and with support for folders.
  • Loading branch information
khmarbaise committed Jul 25, 2016
1 parent 4aa54a2 commit 6731ab5
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 10 deletions.
16 changes: 16 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@

### API Changes

[Fixed issue 169 Add crumbFlag to renameJob][issue-169]

Added supplemental `renameJob` method which supports crumbFlag. Furthermore
added `renameJob` which supports folder with and without `crumbFlag`.
So we now have the following methods to rename jobs:

```java
public class JenkinsServer {
public void renameJob(String oldJobName, String newJobName) throws IOException;
public void renameJob(String oldJobName, String newJobName, Boolean crumbFlag) throws IOException;
public void renameJob(FolderJob folder, String oldJobName, String newJobName) throws IOException;
public void renameJob(FolderJob folder, String oldJobName, String newJobName, Boolean crumbFlag) throws IOException;
}
```

[Changing getLocalContext(), setLocalContext()][pull-163]

The protected method `getLocalContext()` now returns
Expand Down Expand Up @@ -514,6 +529,7 @@ TestReport testReport = mavenJob.getLastSuccessfulBuild().getTestReport();
[issue-162]: https://github.com/jenkinsci/java-client-api/issues/162
[issue-165]: https://github.com/jenkinsci/java-client-api/issues/165
[issue-167]: https://github.com/jenkinsci/java-client-api/issues/167
[issue-169]: https://github.com/jenkinsci/java-client-api/issues/169
[issue-172]: https://github.com/jenkinsci/java-client-api/issues/172
[pull-123]: https://github.com/jenkinsci/java-client-api/pull/123
[pull-149]: https://github.com/jenkinsci/java-client-api/pull/149
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,14 +651,74 @@ public Build getBuild(QueueItem q) throws IOException {
}

/**
* Rename a job
*
* @param jobName Existing Job name
* @param newJobName New Job Name
* @throws IOException In case of a failure.
*/
public void renameJob(String jobName, String newJobName) throws IOException {
client.post(
"/job/" + EncodingUtils.encode(jobName) + "/doRename?newName=" + EncodingUtils.encodeParam(newJobName));
}
* Rename a job
*
* @param oldJobName
* existing job name.
* @param newJobName
* The new job name.
* @throws IOException
* In case of a failure.
*/
public void renameJob(String oldJobName, String newJobName) throws IOException {
renameJob(null, oldJobName, newJobName, false);
}

/**
* Rename a job
*
* @param oldJobName
* existing job name.
* @param newJobName
* The new job name.
* @param crumbFlag
* <code>true</code> to add <b>crumbIssuer</b> <code>false</code> otherwise.
* @throws IOException
* In case of a failure.
*/
public void renameJob(String oldJobName, String newJobName, Boolean crumbFlag) throws IOException {
renameJob(null, oldJobName, newJobName, crumbFlag);
}

/**
* Rename a job
*
* @param FolderJob
* The folder.
* @param oldJobName
* existing job name.
* @param newJobName
* The new job name.
* @throws IOException
* In case of a failure.
*/
public void renameJob(FolderJob folder, String oldJobName, String newJobName) throws IOException {
renameJob(folder, oldJobName, newJobName, false);
}

/**
* Rename a job
*
* @param FolderJob
* The folder.
* @param oldJobName
* existing job name.
* @param newJobName
* The new job name.
* @param crumbFlag
* <code>true</code> to add <b>crumbIssuer</b> <code>false</code> otherwise.
* @throws IOException
* In case of a failure.
*/
public void renameJob(FolderJob folder, String oldJobName, String newJobName, Boolean crumbFlag) throws IOException {

String path = "/";
if (folder != null) {
path = folder.getUrl();
}
client.post( path +
"job/" + EncodingUtils.encode(oldJobName) + "/doRename?newName=" + EncodingUtils.encodeParam(newJobName), crumbFlag);

}

}

0 comments on commit 6731ab5

Please sign in to comment.