Skip to content

Commit

Permalink
Fixed #211
Browse files Browse the repository at this point in the history
 o Added methods to update/clear the description of a job.
  • Loading branch information
khmarbaise committed Dec 3, 2016
1 parent 1b0c1e8 commit 5968565
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
13 changes: 13 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@

### API Changes

* [Fixed issue 211][issue-211]

Added methods to update/clear the description of a job.

```java
public class JobWithDetails .. {
public void updateDescription(String description);
public void updateDescription(String description, boolean crumbFlag);
public void clearDescription();
public void clearDescription(boolean crumbFlag);
```

* [Fixed issue 188][issue-188]

Added methods to update the description and the display name of a build.
Expand Down Expand Up @@ -773,6 +785,7 @@ TestReport testReport = mavenJob.getLastSuccessfulBuild().getTestReport();
[issue-202]: https://github.com/jenkinsci/java-client-api/issues/202
[issue-203]: https://github.com/jenkinsci/java-client-api/issues/203
[issue-207]: https://github.com/jenkinsci/java-client-api/issues/207
[issue-211]: https://github.com/jenkinsci/java-client-api/issues/211
[pull-123]: https://github.com/jenkinsci/java-client-api/pull/123
[pull-149]: https://github.com/jenkinsci/java-client-api/pull/149
[pull-158]: https://github.com/jenkinsci/java-client-api/pull/158
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

import org.apache.http.HttpStatus;
import org.apache.http.client.HttpResponseException;

import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import com.offbytwo.jenkins.client.util.EncodingUtils;
import com.offbytwo.jenkins.helper.Range;
Expand Down Expand Up @@ -339,9 +341,10 @@ public QueueItem getQueueItem() {
/**
* Get a build by the given buildNumber.
*
* @param buildNumber The number to select the build by.
* @param buildNumber
* The number to select the build by.
* @return The {@link Build} selected by the given buildnumber
*
*
*/
public Build getBuildByNumber(final int buildNumber) {

Expand All @@ -366,6 +369,66 @@ public Job apply(Job job) {
}
}

/**
* Empty description to be used for {@link #updateDescription(String)}
* or {@link #updateDescription(String, boolean)}.
*/
public static final String EMPTY_DESCRIPTION = "";

/**
* Update the <code>description</code> of a Job.
*
* @param description
* The description which should be set.
* If you like to set an empty description
* you should use {@link #EMPTY_DESCRIPTION}.
* @throws IOException
* in case of errors.
*/
public void updateDescription(String description) throws IOException {
updateDescription(description, false);
}

/**
* Update the <code>description</code> of a Job.
*
* @param description
* The description which should be set.
* If you like to set an empty description
* you should use {@link #EMPTY_DESCRIPTION}.
* @param crumbFlag
* <code>true</code> or <code>false</code>.
* @throws IOException
* in case of errors.
*/
public void updateDescription(String description, boolean crumbFlag) throws IOException {
Objects.requireNonNull(description, "description is not allowed to be null.");
ImmutableMap<String, String> params = ImmutableMap.of("description", description);
client.post_form(this.getUrl() + "/submitDescription?", params, crumbFlag);
}

/**
* clear the description of a job.
*
* @throws IOException
* in case of errors.
*/
public void clearDescription() throws IOException {
updateDescription(EMPTY_DESCRIPTION);
}

/**
* clear the description of a job.
*
* @param crumbFlag
* <code>true</code> or <code>false</code>.
* @throws IOException
* in case of errors.
*/
public void clearDescription(boolean crumbFlag) throws IOException {
updateDescription(EMPTY_DESCRIPTION, crumbFlag);
}

@Override
public int hashCode() {
final int prime = 31;
Expand Down

0 comments on commit 5968565

Please sign in to comment.