Merge remote-tracking branch 'origin/master' into develop

This commit is contained in:
Dimitris Stafylarakis 2014-12-28 06:39:41 +01:00
commit 9ee33217d4
2 changed files with 24 additions and 2 deletions

View File

@ -302,7 +302,8 @@ public class GitLabPushTrigger extends Trigger<AbstractProject<?, ?>> {
if (!gitlabHostUrl.isEmpty() && (null != sourceRepository)) {
List<GitlabProject> projects = getGitlab().instance().getProjects();
for (GitlabProject project : projects) {
if(project.getSshUrl().equalsIgnoreCase(sourceRepository.toString())){
if(project.getSshUrl().equalsIgnoreCase(sourceRepository.toString()) ||
project.getHttpUrl().equalsIgnoreCase(sourceRepository.toString())){
//Get all branches of project
List<GitlabBranch> branches = getGitlab().instance().getBranches(project);
for (GitlabBranch branch : branches){

View File

@ -15,6 +15,7 @@ import hudson.plugins.git.util.Build;
import hudson.plugins.git.util.BuildData;
import hudson.scm.SCM;
import hudson.security.ACL;
import hudson.security.csrf.CrumbExclusion;
import hudson.util.HttpResponses;
import java.io.IOException;
@ -29,7 +30,10 @@ import java.util.ListIterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jenkins.model.Jenkins;
import net.sf.json.JSONObject;
@ -505,7 +509,7 @@ public class GitLabWebHook implements UnprotectedRootAction {
* @param rsp The stapler response to write the output to.
* @throws IOException
*/
private void writeJSON(StaplerResponse rsp, JSONObject jsonObject) throws IOException {
private void writeJSON(StaplerResponse rsp, JSONObject jsonObject) throws IOException {
rsp.setContentType("application/json");
PrintWriter w = rsp.getWriter();
@ -520,4 +524,21 @@ public class GitLabWebHook implements UnprotectedRootAction {
}
@Extension
public static class GitlabWebHookCrumbExclusion extends CrumbExclusion {
@Override
public boolean process(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws IOException, ServletException {
String pathInfo = req.getPathInfo();
if (pathInfo != null && pathInfo.startsWith(getExclusionPath())) {
chain.doFilter(req, resp);
return true;
}
return false;
}
private String getExclusionPath() {
return '/' + WEBHOOK_URL + '/';
}
}
}