diff --git a/src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java b/src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java index 3c47d2e..6bac2c7 100755 --- a/src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java +++ b/src/main/java/org/jenkinsci/plugins/urltrigger/URLTrigger.java @@ -288,7 +288,8 @@ private boolean checkIfModifiedEntryForHttpOrHttpsURL(URLTriggerResolvedEntry re List< URLTriggerRequestHeader > requestHeaders = resolvedEntry.getEntry().getRequestHeaders() ; if( requestHeaders.size() > 0 ) { for( URLTriggerRequestHeader requestHeader : requestHeaders ) { - log.info("Adding header - " + requestHeader.headerName + ":" + requestHeader.headerValue) ; + String safeValue = requestHeader.maskValue ? "" : requestHeader.headerValue ; + log.info("Adding header - " + requestHeader.headerName + ":" + safeValue) ; webResourceBuilder = webResourceBuilder.header(requestHeader.headerName, requestHeader.headerValue) ; } } @@ -684,25 +685,25 @@ private URLTriggerEntry fillAndGetEntry(StaplerRequest req, JSONObject entryObje //Process requestHeaders List< URLTriggerRequestHeader > requestHeaders = new ArrayList<>() ; Object requestHeaderListObject = entryObject.get("urlRequestHeaders") ; + JSONArray requestHeaderListArray; if( requestHeaderListObject instanceof JSONObject ) { - JSONObject requestHeaderItem = (JSONObject) requestHeaderListObject ; - String headerName = Util.fixEmpty(requestHeaderItem.getString("headerName")) ; - String headerValue = Util.fixEmpty(requestHeaderItem.getString("headerValue" )) ; - if( headerName != null && headerValue != null ) { - requestHeaders.add( new URLTriggerRequestHeader( headerName , headerValue ) ) ; - } + requestHeaderListArray = new JSONArray(); + requestHeaderListArray.add( requestHeaderListObject ); } else { - JSONArray requestHeaderListArray = (JSONArray) requestHeaderListObject ; - if( requestHeaderListArray != null ) { - for( Object requestHeaderItemObject : requestHeaderListArray ) { - JSONObject requestHeaderItem = (JSONObject) requestHeaderItemObject ; - String headerName = Util.fixEmpty(requestHeaderItem.getString("headerName")) ; - String headerValue = Util.fixEmpty(requestHeaderItem.getString("headerValue" )) ; - if( headerName != null && headerValue != null ) { - requestHeaders.add( new URLTriggerRequestHeader( headerName , headerValue ) ) ; - } } - } + requestHeaderListArray = (JSONArray) requestHeaderListObject ; } + + if( requestHeaderListArray != null ) { + for( Object requestHeaderItemObject : requestHeaderListArray ) { + JSONObject requestHeaderItem = (JSONObject) requestHeaderItemObject ; + String headerName = Util.fixEmpty(requestHeaderItem.getString("headerName")) ; + String headerValue = Util.fixEmpty(requestHeaderItem.getString("headerValue" )) ; + if( headerName != null && headerValue != null ) { + requestHeaders.add( new URLTriggerRequestHeader( headerName , headerValue , requestHeaderItem.getBoolean("maskValue")) ) ; + } + } + } + urlTriggerEntry.setRequestHeaders(requestHeaders); //Process inspectingContent diff --git a/src/main/java/org/jenkinsci/plugins/urltrigger/URLTriggerRequestHeader.java b/src/main/java/org/jenkinsci/plugins/urltrigger/URLTriggerRequestHeader.java index 2d01c0a..1403ee5 100644 --- a/src/main/java/org/jenkinsci/plugins/urltrigger/URLTriggerRequestHeader.java +++ b/src/main/java/org/jenkinsci/plugins/urltrigger/URLTriggerRequestHeader.java @@ -20,7 +20,17 @@ public class URLTriggerRequestHeader implements Serializable, Describable getDescriptor() { @@ -61,7 +72,7 @@ public String getDisplayName() { } public static URLTriggerRequestHeader[] getDefaults() { - return new URLTriggerRequestHeader[] { new URLTriggerRequestHeader( "" , "" ) } ; + return new URLTriggerRequestHeader[] { new URLTriggerRequestHeader( "" , "" , false) } ; } } \ No newline at end of file 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 c24b1c0..e65e70b 100644 --- a/src/main/resources/org/jenkinsci/plugins/urltrigger/URLTrigger/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/urltrigger/URLTrigger/config.jelly @@ -67,6 +67,13 @@ + + +