webhook url 调整以避免与gitlab 插件冲突
This commit is contained in:
parent
66dca0a0b9
commit
0c92699581
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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());
|
||||
|
||||
|
|
Loading…
Reference in New Issue