Skip to content

Commit

Permalink
Updating fmt-maven-plugin
Browse files Browse the repository at this point in the history
 * Adding another simpler test case on request parameters
 * Testing github tag push
 * Adding more testcases on Bitbucket Server and Cloud
  • Loading branch information
tomasbjerre committed Sep 5, 2018
1 parent fae3e86 commit df9e012
Show file tree
Hide file tree
Showing 58 changed files with 2,483 additions and 137 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
target
work
.idea
*iml
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Generic Webhook Plugin Changelog
Changelog of Generic Webhook Plugin.
## Unreleased
### No issue

**Adding more testcases on Bitbucket Server and Cloud**


[f0309fe0263be8b](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/f0309fe0263be8b) Tomas Bjerre *2018-09-04 09:04:58*

**Updating fmt-maven-plugin**

* Adding another simpler test case on request parameters
* Testing github tag push

[a1522b6680bcf99](https://github.com/jenkinsci/generic-webhook-trigger-plugin/commit/a1522b6680bcf99) Tomas Bjerre *2018-09-02 06:38:31*


## 1.43 (2018-08-25 14:03:35)
### GitHub [#70](https://github.com/jenkinsci/generic-webhook-trigger-plugin/issues/70) How to specify the TOKEN using Job DSL? *question*

Expand Down
9 changes: 6 additions & 3 deletions ISSUE_TEMPLATE
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
When reporting a bug, please try to provide as much information as possible.
When reporting a bug, please **try** to provide as much information as possible.

* Plugin version used.
* Jenkins version used.
* Your configuration.
* Variables configured, names, expressions...
* Variables configured, names, expressions...
* Pipeline script
* Build job log
* Post content received. It can be found in the job execution log. People using GitHub often forget to set the content type in "Manage webhook" when configuring the webhook at GitHub.
* A `curl` command and its response.
* Expected result and actual result.
Expand All @@ -13,7 +16,7 @@ You may also have a look at the test cases as they should answer the most common

If you are fiddling with expressions, you may want to checkout:

* [This JSONPath site](https://jsonpath.curiousconcept.com/)
* [This JSONPath site](http://jsonpath.herokuapp.com/)
* [This XPath site](http://www.freeformatter.com/xpath-tester.html)
* [This regexp site](https://jex.im/regulex/)

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

This is a Jenkins plugin that can:

1. Receive any HTTP request, JENKINS_URL/generic-webhook-trigger/invoke
1. Receive any HTTP request, `JENKINS_URL/generic-webhook-trigger/invoke`
2. Extract values

* From POST content with [JSONPath](https://github.com/json-path/JsonPath) or [XPath](https://www.w3schools.com/xml/xpath_syntax.asp)
* From the query parameters
* From the headers
* From `POST` content with [JSONPath](https://github.com/json-path/JsonPath) or [XPath](https://www.w3schools.com/xml/xpath_syntax.asp)
* From the `query` parameters
* From the `headers`

3. Trigger a build with those values contribute as variables

Expand Down Expand Up @@ -68,7 +68,7 @@ The token can be supplied as a:

If you are fiddling with expressions, you may want to checkout:

* [This JSONPath site](https://jsonpath.curiousconcept.com/)
* [This JSONPath site](http://jsonpath.herokuapp.com/)
* [This XPath site](http://www.freeformatter.com/xpath-tester.html)
* [This regexp site](https://jex.im/regulex/)

Expand Down
2 changes: 1 addition & 1 deletion debug.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh
mvnDebug -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.121.1 -Denforcer.skip=true
mvnDebug -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.121.3 -Denforcer.skip=true

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Changelog of Generic Webhook Plugin.
<plugin>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>1.3.0</version>
<version>2.5.1</version>
<executions>
<execution>
<goals>
Expand Down
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/sh
mvn -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.121.1 -Denforcer.skip=true
mvn -q hpi:run -Djava.util.logging.config.file=logging.properties -Djenkins.version=2.121.3 -Denforcer.skip=true
25 changes: 25 additions & 0 deletions sandbox/pipeline.jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
pipeline {
agent any
triggers {
GenericTrigger(
genericVariables: [
[key: 'ref', value: '$.ref']
],

causeString: 'Triggered on $ref',

printContributedVariables: true,
printPostContent: true,

regexpFilterText: '$ref',
regexpFilterExpression: 'refs/heads/master'
)
}
stages {
stage('Some step') {
steps {
sh "echo $ref"
}
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/org/jenkinsci/plugins/gwt/GenericCause.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jenkinsci.plugins.gwt;

import static com.google.common.base.Strings.isNullOrEmpty;
import hudson.model.Cause;

import hudson.model.Cause;
import java.util.Map;

public class GenericCause extends Cause {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.jenkinsci.plugins.gwt;

import static com.google.common.base.Preconditions.checkNotNull;

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;

import org.kohsuke.stapler.DataBoundConstructor;

public class GenericHeaderVariable extends AbstractDescribableImpl<GenericHeaderVariable> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.jenkinsci.plugins.gwt;

import static com.google.common.base.Preconditions.checkNotNull;

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;

import org.kohsuke.stapler.DataBoundConstructor;

public class GenericRequestVariable extends AbstractDescribableImpl<GenericRequestVariable> {
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/org/jenkinsci/plugins/gwt/GenericTrigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
import static org.jenkinsci.plugins.gwt.Renderer.isMatching;
import static org.jenkinsci.plugins.gwt.Renderer.renderText;

import java.util.List;
import java.util.Map;

import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.gwt.resolvers.VariablesResolver;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import hudson.Extension;
import hudson.model.CauseAction;
import hudson.model.Item;
Expand All @@ -21,7 +13,13 @@
import hudson.model.ParametersDefinitionProperty;
import hudson.triggers.Trigger;
import hudson.triggers.TriggerDescriptor;
import java.util.List;
import java.util.Map;
import jenkins.model.ParameterizedJobMixIn;
import org.jenkinsci.Symbol;
import org.jenkinsci.plugins.gwt.resolvers.VariablesResolver;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

public class GenericTrigger extends Trigger<Job<?, ?>> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import static com.google.common.base.Preconditions.checkNotNull;
import static org.jenkinsci.plugins.gwt.ExpressionType.JSONPath;

import hudson.Extension;
import hudson.model.AbstractDescribableImpl;
import hudson.model.Descriptor;

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,26 @@
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.SEVERE;

import com.google.common.annotations.VisibleForTesting;
import hudson.Extension;
import hudson.model.UnprotectedRootAction;
import hudson.security.csrf.CrumbExclusion;
import java.io.IOException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.io.IOUtils;
import org.jenkinsci.plugins.gwt.jobfinder.JobFinder;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.StaplerRequest;

import com.google.common.annotations.VisibleForTesting;

import hudson.Extension;
import hudson.model.UnprotectedRootAction;
import hudson.security.csrf.CrumbExclusion;

@Extension
public class GenericWebHookRequestReceiver extends CrumbExclusion implements UnprotectedRootAction {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package org.jenkinsci.plugins.gwt;

import com.google.common.base.Charsets;
import hudson.EnvVars;
import hudson.Extension;
import hudson.model.TaskListener;
import hudson.model.EnvironmentContributor;
import hudson.model.Run;

import hudson.model.TaskListener;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;

import javax.annotation.Nonnull;

import com.google.common.base.Charsets;

@Extension
public class GenericWebhookEnvironmentContributor extends EnvironmentContributor {
private static final String CONTRIBUTING_VARIABLES =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.Lists.newArrayList;

import java.util.List;
import java.util.Map;

import com.cloudbees.plugins.credentials.CredentialsParameterValue;

import hudson.model.BooleanParameterValue;
import hudson.model.ParameterDefinition;
import hudson.model.ParameterValue;
import hudson.model.ParametersAction;
import hudson.model.ParametersDefinitionProperty;
import hudson.model.StringParameterValue;
import java.util.List;
import java.util.Map;

public class ParameterActionUtil {

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/org/jenkinsci/plugins/gwt/Renderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static java.util.logging.Level.FINE;
import static java.util.regex.Pattern.compile;

import com.google.common.annotations.VisibleForTesting;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand All @@ -12,8 +13,6 @@
import java.util.Set;
import java.util.logging.Logger;

import com.google.common.annotations.VisibleForTesting;

public class Renderer {
private static Logger LOGGER = Logger.getLogger(Renderer.class.getSimpleName());

Expand Down
13 changes: 5 additions & 8 deletions src/main/java/org/jenkinsci/plugins/gwt/jobfinder/JobFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,16 @@

import static com.google.common.base.Strings.isNullOrEmpty;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.jenkinsci.plugins.gwt.FoundJob;
import org.jenkinsci.plugins.gwt.GenericTrigger;

import com.google.common.annotations.VisibleForTesting;

import hudson.model.BuildAuthorizationToken;
import hudson.triggers.Trigger;
import hudson.triggers.TriggerDescriptor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import jenkins.model.ParameterizedJobMixIn.ParameterizedJob;
import org.jenkinsci.plugins.gwt.FoundJob;
import org.jenkinsci.plugins.gwt.GenericTrigger;

public final class JobFinder {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package org.jenkinsci.plugins.gwt.jobfinder;

import java.util.List;

import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;

import hudson.security.ACL;
import java.util.List;
import jenkins.model.Jenkins;
import jenkins.model.ParameterizedJobMixIn.ParameterizedJob;
import org.acegisecurity.context.SecurityContext;
import org.acegisecurity.context.SecurityContextHolder;

public class JobFinderImpersonater {
public List<ParameterizedJob> getAllParameterizedJobsByImpersonation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
import static org.jenkinsci.plugins.gwt.resolvers.FlattenerUtils.filter;
import static org.jenkinsci.plugins.gwt.resolvers.FlattenerUtils.toVariableName;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JsonFlattener {
private static Gson GSON =
new GsonBuilder() //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,25 @@
import static org.jenkinsci.plugins.gwt.ExpressionType.JSONPath;
import static org.jenkinsci.plugins.gwt.ExpressionType.XPath;

import com.google.common.base.Charsets;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
import java.io.ByteArrayInputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathFactory;

import org.jenkinsci.plugins.gwt.GenericVariable;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;

import com.google.common.base.Charsets;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;

public class PostContentParameterResolver {
private static final Logger LOGGER = Logger.getLogger(VariablesResolver.class.getName());

Expand Down
Loading

0 comments on commit df9e012

Please sign in to comment.