Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
fixes fabric8io/fabric8-forge#624 so we add a github hook for github …
Browse files Browse the repository at this point in the history
…based projects
  • Loading branch information
jstrachan committed Oct 18, 2016
1 parent 2ef7526 commit 0a75ad5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/fabric8-devops-connector/pom.xml
Expand Up @@ -49,6 +49,10 @@
<artifactId>gitrepo-api</artifactId>
</dependency>
-->
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>fabric8-project-utils</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>letschat-api</artifactId>
Expand Down
Expand Up @@ -40,6 +40,7 @@
import io.fabric8.openshift.api.model.BuildSource;
import io.fabric8.openshift.api.model.GitBuildSource;
import io.fabric8.openshift.client.OpenShiftClient;
import io.fabric8.project.support.GitUtils;
import io.fabric8.repo.git.GitRepoClient;
import io.fabric8.repo.git.GitRepoKubernetes;
import io.fabric8.taiga.ModuleDTO;
Expand All @@ -50,6 +51,7 @@
import io.fabric8.utils.DomHelper;
import io.fabric8.utils.GitHelpers;
import io.fabric8.utils.IOHelpers;
import io.fabric8.utils.Objects;
import io.fabric8.utils.Strings;
import io.fabric8.utils.Systems;
import io.fabric8.utils.URLUtils;
Expand Down Expand Up @@ -97,6 +99,8 @@
import java.io.StringReader;
import java.net.ConnectException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -1085,6 +1089,16 @@ protected void addJenkinsScmTrigger(String jenkinsJobUrl) {
} else {
triggerElement = (Element) triggers.item(0);
}
String hostName = GitUtils.getGitHostName(gitUrl);
getLog().info("using git host: " + hostName);
if (Objects.equal("github.com", hostName)) {
Element githubTrigger = DomHelper.firstChild(triggerElement, "com.cloudbees.jenkins.GitHubPushTrigger");
if (githubTrigger == null) {
githubTrigger = DomHelper.addChildElement(triggerElement, "com.cloudbees.jenkins.GitHubPushTrigger");
githubTrigger.setAttribute("plugin", "github@1.14.0");
DomHelper.addChildElement(githubTrigger, "spec");
}
}
Element scmTrigger = DomHelper.addChildElement(triggerElement, "hudson.triggers.SCMTrigger");
DomHelper.addChildElement(scmTrigger, "spec", "* * * * * ");
DomHelper.addChildElement(scmTrigger, "ignorePostCommitHooks", "false");
Expand Down

0 comments on commit 0a75ad5

Please sign in to comment.