From 0689de224de36fb1661b4417f9a5a8543d6cefe3 Mon Sep 17 00:00:00 2001 From: Andras Elso Date: Sun, 11 Feb 2024 01:26:28 +0100 Subject: [PATCH] Allow follow 302 redirects --- .../jenkinsci/plugins/urltrigger/URLTrigger.java | 3 ++- .../plugins/urltrigger/URLTriggerEntry.java | 13 ++++++++++++- .../plugins/urltrigger/URLTrigger/config.jelly | 8 ++++++++ .../urltrigger/URLTrigger/help-followRedirects.html | 5 +++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/main/resources/org/jenkinsci/plugins/urltrigger/URLTrigger/help-followRedirects.html diff --git a/src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java b/src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java index 5d59e52..3c47d2e 100755 --- a/src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java +++ b/src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java @@ -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; } @@ -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")); diff --git a/src/main/java/org/jenkinsci/plugins/urltrigger/URLTriggerEntry.java b/src/main/java/org/jenkinsci/plugins/urltrigger/URLTriggerEntry.java index d882950..e42a929 100755 --- a/src/main/java/org/jenkinsci/plugins/urltrigger/URLTriggerEntry.java +++ b/src/main/java/org/jenkinsci/plugins/urltrigger/URLTriggerEntry.java @@ -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; @@ -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; @@ -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; } diff --git a/src/main/resources/org/jenkinsci/plugins/urltrigger/URLTrigger/config.jelly b/src/main/resources/org/jenkinsci/plugins/urltrigger/URLTrigger/config.jelly index 4490b33..c24b1c0 100644 --- a/src/main/resources/org/jenkinsci/plugins/urltrigger/URLTrigger/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/urltrigger/URLTrigger/config.jelly @@ -22,6 +22,14 @@ title="${%Activate the Jenkins Proxy}"/> + + + + +

+ Follow redirects. +

+ \ No newline at end of file