Skip to content

Commit

Permalink
Merge pull request #119 from Elbandi/feature/follow-redirects
Browse files Browse the repository at this point in the history
Allow follow 302 redirects
  • Loading branch information
TonyNoble committed Sep 3, 2024
2 parents fd3ec13 + 0689de2 commit 8240111
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private Client getClientObject(URLTriggerResolvedEntry resolvedEntry, XTriggerLo
if (isAuthBasic(entry)) {
addBasicAuth(entry, log, client);
}

client.property(ClientProperties.FOLLOW_REDIRECTS, entry.isFollowRedirects());
return client;
}

Expand Down Expand Up @@ -637,6 +637,7 @@ public URLTrigger newInstance(StaplerRequest req, JSONObject formData) throws Fo
private URLTriggerEntry fillAndGetEntry(StaplerRequest req, JSONObject entryObject) {
URLTriggerEntry urlTriggerEntry = new URLTriggerEntry();
urlTriggerEntry.setUrl(entryObject.getString("url"));
urlTriggerEntry.setFollowRedirects(entryObject.getBoolean("followRedirects"));
urlTriggerEntry.setProxyActivated(entryObject.getBoolean("proxyActivated"));
urlTriggerEntry.setUseGlobalEnvVars(entryObject.getBoolean("useGlobalEnvVars"));
String username = Util.fixEmpty(entryObject.getString("username"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class URLTriggerEntry implements Serializable , Describable< URLTriggerEn
private String url;
private String username;
private String password;
private boolean followRedirects = false ;
private boolean proxyActivated = false ;
private boolean checkStatus = false ;
private int statusCode;
Expand Down Expand Up @@ -59,10 +60,11 @@ public URLTriggerEntry( String url ) {
this.url = url ;
}

public URLTriggerEntry(String url, String username, String password, boolean proxyActivated, boolean checkStatus, int statusCode, int timeout, boolean checkETag, boolean checkLastModificationDate, boolean inspectingContent, URLTriggerContentType[] contentTypes, String ETag, long lastModificationDate) {
public URLTriggerEntry(String url, String username, String password, boolean followRedirects, boolean proxyActivated, boolean checkStatus, int statusCode, int timeout, boolean checkETag, boolean checkLastModificationDate, boolean inspectingContent, URLTriggerContentType[] contentTypes, String ETag, long lastModificationDate) {
this.url = url;
this.username = username;
this.password = password;
this.followRedirects = followRedirects;
this.proxyActivated = proxyActivated;
this.checkStatus = checkStatus;
this.statusCode = statusCode;
Expand Down Expand Up @@ -111,6 +113,15 @@ public void setPassword(String password) {
this.password = password;
}

public boolean isFollowRedirects() {
return followRedirects;
}

@DataBoundSetter
public void setFollowRedirects(boolean followRedirects) {
this.followRedirects = followRedirects;
}

public boolean isProxyActivated() {
return proxyActivated;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
title="${%Activate the Jenkins Proxy}"/>
</f:entry>

<f:entry field="followRedirects">
<f:checkbox
field="followRedirects"
name="urlElements.followRedirects"
checked="${urlElements.followRedirects}"
title="${%Follow Redirects}"/>
</f:entry>

<f:entry field="useGlobalEnvVars">
<f:checkbox
field="useGlobalEnvVars"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div>
<p>
Follow redirects.
</p>
</div>

0 comments on commit 8240111

Please sign in to comment.