webhook url 调整以避免与gitlab 插件冲突

This commit is contained in:
yashin 2019-11-15 19:59:19 +08:00
parent 66dca0a0b9
commit 0c92699581
2 changed files with 62 additions and 1 deletions

View File

@ -0,0 +1,60 @@
package com.gitee.jenkins.webhook;
import hudson.Extension;
import hudson.model.UnprotectedRootAction;
import hudson.security.csrf.CrumbExclusion;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* @author Daniel Brooks
* @author Yashin Luo
*/
@Extension
public class GiteeOldWebHook implements UnprotectedRootAction {
public static final String WEBHOOK_URL = "project";
private static final Logger LOGGER = Logger.getLogger(GiteeOldWebHook.class.getName());
private transient final ActionResolver actionResolver = new ActionResolver();
public String getIconFileName() {
return null;
}
public String getDisplayName() {
return null;
}
public String getUrlName() {
return WEBHOOK_URL;
}
public void getDynamic(final String projectName, final StaplerRequest request, StaplerResponse response) {
LOGGER.log(Level.INFO, "WebHook called with url: {0}", request.getRequestURIWithQueryString());
actionResolver.resolve(projectName, request).execute(response);
}
@Extension
public static class GiteeWebHookCrumbExclusion extends CrumbExclusion {
@Override
public boolean process(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws IOException, ServletException {
String pathInfo = req.getPathInfo();
if (pathInfo != null && pathInfo.startsWith('/' + WEBHOOK_URL + '/')) {
chain.doFilter(req, resp);
return true;
}
return false;
}
}
}

View File

@ -16,12 +16,13 @@ import java.util.logging.Logger;
/**
* @author Daniel Brooks
* @author Yashin Luo
*/
@Extension
public class GiteeWebHook implements UnprotectedRootAction {
public static final String WEBHOOK_URL = "project";
public static final String WEBHOOK_URL = "gitee-project";
private static final Logger LOGGER = Logger.getLogger(GiteeWebHook.class.getName());