Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Aug 16, 2017
1 parent 66ec0ca commit a54279d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 36 deletions.
20 changes: 19 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# Generic Webhook Plugin Changelog
Changelog of Generic Webhook Plugin.
## Unreleased
### GitHub [#20](https://github.com/jenkinsci/generic-webhook-trigger-plugin/issues/20) Header Variables cannot be reused through several webhook triggered jobs

**fix #20: Header Variables cannot be reused through several webhook triggered jobs**


[5c74d73d14093a5](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/5c74d73d14093a5) Juan Pablo Santos Rodríguez *2017-08-16 10:53:02*


### No issue

**fix failing tests, should ran them before; seems they were checking for incorrect number of parameters, regardless(?) the previous Enumeration -> List change**


[10d8f40afee5693](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/10d8f40afee5693) Juan Pablo Santos Rodríguez *2017-08-16 11:17:34*

**Refactoring**


[63ca30f7c54ab75](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/63ca30f7c54ab75) Tomas Bjerre *2017-08-11 14:24:25*
[05ac39f8cb39e8d](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/05ac39f8cb39e8d) Tomas Bjerre *2017-08-13 06:35:14*

**doc**

Expand All @@ -18,6 +31,11 @@ Changelog of Generic Webhook Plugin.

[7468387fbc3791e](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/7468387fbc3791e) Tomas Bjerre *2017-08-10 18:52:28*

**doc**


[934742625d102f2](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/934742625d102f2) Tomas Bjerre *2017-07-17 16:08:00*


## 1.18 (2017-08-10 18:13:06)
### GitHub [#18](https://github.com/jenkinsci/generic-webhook-trigger-plugin/issues/18) How to access request header variables?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,21 @@ public Map<String, String> getRequestHeaders(
final Enumeration<String> headerEnumeration = incomingHeaders.get(headerName);
List<String> headers = Collections.list(headerEnumeration); // "depletes" headerEnumeration
int i = 0;
for(String headerValue : headers) {
final String regexpFilter = configuredVariable.get().getRegexpFilter();
final String filteredValue = filter(headerValue, regexpFilter);
found.put(toVariableName(headerName) + "_" + i, filteredValue);
final boolean firstAndOnlyValue = i == 0 && !headerEnumeration.hasMoreElements();
if (firstAndOnlyValue) {
//Users will probably expect this variable for parameters that are never a list
found.put(toVariableName(headerName), filteredValue);
}
i++;
for (String headerValue : headers) {
final String regexpFilter = configuredVariable.get().getRegexpFilter();
final String filteredValue = filter(headerValue, regexpFilter);
found.put(toVariableName(headerName) + "_" + i, filteredValue);
final boolean firstAndOnlyValue = i == 0 && !headerEnumeration.hasMoreElements();
if (firstAndOnlyValue) {
//Users will probably expect this variable for parameters that are never a list
found.put(toVariableName(headerName), filteredValue);
}
i++;
}
incomingHeaders.put(headerName, Collections.enumeration(headers)); // "replete" headerEnumeration, so it can be reused by other jobs later on
incomingHeaders.put(
headerName,
Collections.enumeration(
headers)); // "replete" headerEnumeration, so it can be reused by other jobs later on
}
return found;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,32 +138,32 @@ public void testHeaderResolvesCanBeReused() throws Exception {
List<GenericHeaderVariable> genericHeaderVariables = new ArrayList<>();
genericHeaderVariables.add(new GenericHeaderVariable("someparam", null));
Map<String, String> variables =
new VariablesResolver(
headers,
parameterMap,
postContent,
genericVariables,
genericRequestVariables,
genericHeaderVariables)
.getVariables();

assertThat(variables) //
.containsEntry("someparam", "some value") //
.hasSize(2);
new VariablesResolver(
headers,
parameterMap,
postContent,
genericVariables,
genericRequestVariables,
genericHeaderVariables)
.getVariables();

assertThat(variables) //
.containsEntry("someparam", "some value") //
.hasSize(2);

variables =
new VariablesResolver(
headers,
parameterMap,
postContent,
genericVariables,
genericRequestVariables,
genericHeaderVariables)
.getVariables();

assertThat(variables) //
.containsEntry("someparam", "some value") //
.hasSize(2);
new VariablesResolver(
headers,
parameterMap,
postContent,
genericVariables,
genericRequestVariables,
genericHeaderVariables)
.getVariables();

assertThat(variables) //
.containsEntry("someparam", "some value") //
.hasSize(2);
}

@Test
Expand Down

0 comments on commit a54279d

Please sign in to comment.