Skip to content

fixes #360 by changing the return value from void to the appropriate … #403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 80 additions & 59 deletions jenkins-client/src/main/java/com/offbytwo/jenkins/JenkinsServer.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,27 @@ public String getDisplayPath() {
return displayPath;
}

public void setDisplayPath(String displayPath) {
public Artifact setDisplayPath(String displayPath) {
this.displayPath = displayPath;
return this;
}

public String getFileName() {
return fileName;
}

public void setFileName(String fileName) {
public Artifact setFileName(String fileName) {
this.fileName = fileName;
return this;
}

public String getRelativePath() {
return relativePath;
}

public void setRelativePath(String relativePath) {
public Artifact setRelativePath(String relativePath) {
this.relativePath = relativePath;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public JenkinsHttpConnection getClient() {
* Set the HTTP client.
* @param client {@link JenkinsHttpConnection}.
*/
public void setClient(final JenkinsHttpConnection client) {
public BaseModel setClient(final JenkinsHttpConnection client) {
this.client = client;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,19 @@ public String getUrl() {
return url;
}

protected void setNumber(int number) {
protected Build setNumber(int number) {
this.number = number;
return this;
}

protected void setQueueId(int queueId) {
protected Build setQueueId(int queueId) {
this.queueId = queueId;
return this;
}

protected void setUrl(String url) {
protected Build setUrl(String url) {
this.url = url;
return this;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,48 +29,54 @@ public String getShortDescription() {
return shortDescription;
}

public void setShortDescription(String shortDescription) {
public BuildCause setShortDescription(String shortDescription) {
this.shortDescription = shortDescription;
return this;
}

public int getUpstreamBuild() {
return upstreamBuild;
}

public void setUpstreamBuild(Integer upstreamBuild) {
public BuildCause setUpstreamBuild(Integer upstreamBuild) {
this.upstreamBuild = upstreamBuild;
return this;
}

public String getUpstreamProject() {
return upstreamProject;
}

public void setUpstreamProject(String upstreamProject) {
public BuildCause setUpstreamProject(String upstreamProject) {
this.upstreamProject = upstreamProject;
return this;
}

public String getUpstreamUrl() {
return upstreamUrl;
}

public void setUpstreamUrl(String upstreamUrl) {
public BuildCause setUpstreamUrl(String upstreamUrl) {
this.upstreamUrl = upstreamUrl;
return this;
}

public String getUserId() {
return userId;
}

public void setUserId(String userId) {
public BuildCause setUserId(String userId) {
this.userId = userId;
return this;
}

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
public BuildCause setUserName(String userName) {
this.userName = userName;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public class BuildChangeSet {
/**
* @param items {@link BuildChangeSet}
*/
public void setItems(List<BuildChangeSetItem> items) {
public BuildChangeSet setItems(List<BuildChangeSetItem> items) {
this.items = items;
return this;
}

/**
Expand All @@ -45,8 +46,9 @@ public String getKind() {
/**
* @param kind the kind of (usually svn, git).
*/
public void setKind(String kind) {
public BuildChangeSet setKind(String kind) {
this.kind = kind;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ public String getAbsoluteUrl() {
return absoluteUrl;
}

public void setAbsoluteUrl(String absoluteUrl) {
public BuildChangeSetAuthor setAbsoluteUrl(String absoluteUrl) {
this.absoluteUrl = absoluteUrl;
return this;
}

public String getFullName() {
return fullName;
}

public void setFullName(String fullName) {
public BuildChangeSetAuthor setFullName(String fullName) {
this.fullName = fullName;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,72 +27,81 @@ public List<String> getAffectedPaths() {
return affectedPaths;
}

public void setAffectedPaths(List<String> affectedPaths) {
public BuildChangeSetItem setAffectedPaths(List<String> affectedPaths) {
this.affectedPaths = affectedPaths;
return this;
}

public String getCommitId() {
return commitId;
}

public void setCommitId(String commitId) {
public BuildChangeSetItem setCommitId(String commitId) {
this.commitId = commitId;
return this;
}

public String getTimestamp() {
return timestamp;
}

public void setTimestamp(String timeStamp) {
public BuildChangeSetItem setTimestamp(String timeStamp) {
this.timestamp = timeStamp;
return this;
}

public String getComment() {
return comment;
}

public void setComment(String comment) {
public BuildChangeSetItem setComment(String comment) {
this.comment = comment;
return this;
}

public String getDate() {
return date;
}

public void setDate(String date) {
public BuildChangeSetItem setDate(String date) {
this.date = date;
return this;
}

public String getId() {
return id;
}

public void setId(String id) {
public BuildChangeSetItem setId(String id) {
this.id = id;
return this;
}

public String getMsg() {
return msg;
}

public void setMsg(String msg) {
public BuildChangeSetItem setMsg(String msg) {
this.msg = msg;
return this;
}

public List<BuildChangeSetPath> getPaths() {
return paths;
}

public void setPaths(List<BuildChangeSetPath> paths) {
public BuildChangeSetItem setPaths(List<BuildChangeSetPath> paths) {
this.paths = paths;
return this;
}

public BuildChangeSetAuthor getAuthor() {
return author;
}

public void setAuthor(BuildChangeSetAuthor author) {
public BuildChangeSetItem setAuthor(BuildChangeSetAuthor author) {
this.author = author;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ public String getEditType() {
* @param editType the SCM operation, <code>add</code> or <code>edit</code> or <code>delete</code>
* @see <a href="http://javadoc.jenkins.io/hudson/scm/EditType.html">EditType</a>
*/
public void setEditType(String editType) {
public BuildChangeSetPath setEditType(String editType) {
this.editType = editType;
return this;
}

public String getFile() {
return file;
}

public void setFile(String file) {
public BuildChangeSetPath setFile(String file) {
this.file = file;
return this;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,15 @@ public boolean apply(Map<String, Object> action) {
* @param crumbFlag <code>true</code> or <code>false</code>.
* @throws IOException in case of errors.
*/
public void updateDisplayNameAndDescription(String displayName, String description, boolean crumbFlag)
public BuildWithDetails updateDisplayNameAndDescription(String displayName, String description, boolean crumbFlag)
throws IOException {
Objects.requireNonNull(displayName, "displayName is not allowed to be null.");
Objects.requireNonNull(description, "description is not allowed to be null.");
// TODO: Check what the "core:apply" means?
ImmutableMap<String, String> params = ImmutableMap.of("displayName", displayName, "description", description,
"core:apply", "", "Submit", "Save");
client.post_form(this.getUrl() + "/configSubmit?", params, crumbFlag);
return this;
}

/**
Expand All @@ -217,8 +218,8 @@ public void updateDisplayNameAndDescription(String displayName, String descripti
* @param description The description which should be set.
* @throws IOException in case of errors.
*/
public void updateDisplayNameAndDescription(String displayName, String description) throws IOException {
updateDisplayNameAndDescription(displayName, description, false);
public BuildWithDetails updateDisplayNameAndDescription(String displayName, String description) throws IOException {
return updateDisplayNameAndDescription(displayName, description, false);
}

/**
Expand All @@ -228,13 +229,14 @@ public void updateDisplayNameAndDescription(String displayName, String descripti
* @param crumbFlag <code>true</code> or <code>false</code>.
* @throws IOException in case of errors.
*/
public void updateDisplayName(String displayName, boolean crumbFlag) throws IOException {
public BuildWithDetails updateDisplayName(String displayName, boolean crumbFlag) throws IOException {
Objects.requireNonNull(displayName, "displayName is not allowed to be null.");
String description = getDescription() == null ? "" : getDescription();
// TODO: Check what the "core:apply" means?
ImmutableMap<String, String> params = ImmutableMap.of("displayName", displayName, "description", description,
"core:apply", "", "Submit", "Save");
client.post_form(this.getUrl() + "/configSubmit?", params, crumbFlag);
return this;
}

/**
Expand All @@ -243,8 +245,8 @@ public void updateDisplayName(String displayName, boolean crumbFlag) throws IOEx
* @param displayName The new displayName which should be set.
* @throws IOException in case of errors.
*/
public void updateDisplayName(String displayName) throws IOException {
updateDisplayName(displayName, false);
public BuildWithDetails updateDisplayName(String displayName) throws IOException {
return updateDisplayName(displayName, false);
}

/**
Expand All @@ -254,13 +256,14 @@ public void updateDisplayName(String displayName) throws IOException {
* @param crumbFlag <code>true</code> or <code>false</code>.
* @throws IOException in case of errors.
*/
public void updateDescription(String description, boolean crumbFlag) throws IOException {
public BuildWithDetails updateDescription(String description, boolean crumbFlag) throws IOException {
Objects.requireNonNull(description, "description is not allowed to be null.");
String displayName = getDisplayName() == null ? "" : getDisplayName();
// TODO: Check what the "core:apply" means?
ImmutableMap<String, String> params = ImmutableMap.of("displayName", displayName, "description", description,
"core:apply", "", "Submit", "Save");
client.post_form(this.getUrl() + "/configSubmit?", params, crumbFlag);
return this;
}

/**
Expand All @@ -269,8 +272,8 @@ public void updateDescription(String description, boolean crumbFlag) throws IOEx
* @param description The description which should be set.
* @throws IOException in case of errors.
*/
public void updateDescription(String description) throws IOException {
updateDescription(description, false);
public BuildWithDetails updateDescription(String description) throws IOException {
return updateDescription(description, false);
}

private boolean isNullOrEmpty(String value) {
Expand Down Expand Up @@ -500,8 +503,9 @@ public BuildChangeSet getChangeSet() {
return result;
}

public void setChangeSet(BuildChangeSet changeSet) {
public BuildWithDetails setChangeSet(BuildChangeSet changeSet) {
this.changeSet = changeSet;
return this;
}

/**
Expand All @@ -522,20 +526,23 @@ public List<BuildChangeSet> getChangeSets() {
return result;
}

public void setChangeSets(List<BuildChangeSet> changeSets) {
public BuildWithDetails setChangeSets(List<BuildChangeSet> changeSets) {
this.changeSets = changeSets;
return this;
}

public List<BuildChangeSetAuthor> getCulprits() {
return culprits;
}

public void setCulprits(List<BuildChangeSetAuthor> culprits) {
public BuildWithDetails setCulprits(List<BuildChangeSetAuthor> culprits) {
this.culprits = culprits;
return this;
}

public void setResult(BuildResult result) {
public BuildWithDetails setResult(BuildResult result) {
this.result = result;
return this;
}

public InputStream downloadArtifact(Artifact a) throws IOException, URISyntaxException {
Expand Down
Loading