aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-10 14:27:04 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-10 14:27:04 +0100
commit34f5ac99c81dfe39f986e8133fb7fff22c0d30bc (patch)
treec91d2a0b1ffe4e120a56f7c31905648b2e2e1f61 /src/main/java
parentf6e357ef18a0c44038fc0ea723c1ec7910bb3f30 (diff)
downloadesper-testing-34f5ac99c81dfe39f986e8133fb7fff22c0d30bc.tar.gz
esper-testing-34f5ac99c81dfe39f986e8133fb7fff22c0d30bc.tar.bz2
esper-testing-34f5ac99c81dfe39f986e8133fb7fff22c0d30bc.tar.xz
esper-testing-34f5ac99c81dfe39f986e8133fb7fff22c0d30bc.zip
o Adding Maven module as a build type.
Diffstat (limited to 'src/main/java')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java7
-rwxr-xr-x[-rw-r--r--]src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java7
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java6
-rwxr-xr-x[-rw-r--r--]src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java (renamed from src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java)39
4 files changed, 23 insertions, 36 deletions
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java
index 2b3ca13..0aa63c1 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsClient.java
@@ -119,7 +119,9 @@ public class JenkinsClient {
case "freeStyleProject":
return some(JenkinsJobXml.parse(url, JenkinsJobType.FREE_STYLE, root));
case "mavenModuleSet":
- return some(JenkinsJobXml.parse(url, JenkinsJobType.MAVEN, root));
+ return some(JenkinsJobXml.parse(url, JenkinsJobType.MAVEN_MODULE_SET, root));
+ case "mavenModule":
+ return some(JenkinsJobXml.parse(url, JenkinsJobType.MAVEN_MODULE, root));
case "matrixProject":
return some(JenkinsJobXml.parse(url, JenkinsJobType.MATRIX, root));
default:
@@ -241,7 +243,7 @@ class JenkinsJobEntryXml {
class JenkinsJobXml {
enum JenkinsJobType {
- MAVEN, FREE_STYLE, MATRIX
+ FREE_STYLE, MAVEN_MODULE_SET, MAVEN_MODULE, MATRIX
}
public final JenkinsJobType type;
@@ -313,4 +315,3 @@ class JenkinsJobXml {
child(root, "lastUnsuccessfulBuild").bind(BuildXml.buildXml));
}
}
-
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
index 9f3c752..bd99768 100644..100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
@@ -20,7 +20,7 @@ public class JenkinsDao {
private static final String JENKINS_SERVER = "uuid, created_date, url";
- private static final String JENKINS_JOB = "uuid, created_date, server, url, display_name";
+ private static final String JENKINS_JOB = "uuid, created_date, server, url, job_type, display_name";
private static final String JENKINS_BUILD = "uuid, created_date, job, entry_id, url, result, number, duration, timestamp";
@@ -88,14 +88,15 @@ public class JenkinsDao {
}
}
- public UUID insertJob(UUID server, URI url, Option<String> displayName) throws SQLException {
- try (PreparedStatement s = c.prepareStatement("INSERT INTO jenkins_job(" + JENKINS_JOB + ") VALUES(?, ?, ?, ?, ?)")) {
+ public UUID insertJob(UUID server, URI url, JenkinsJobXml.JenkinsJobType type, Option<String> displayName) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("INSERT INTO jenkins_job(" + JENKINS_JOB + ") VALUES(?, ?, ?, ?, ?, ?)")) {
UUID uuid = UUID.randomUUID();
int i = 1;
s.setString(i++, uuid.toString());
s.setTimestamp(i++, new Timestamp(currentTimeMillis()));
s.setString(i++, server.toString());
s.setString(i++, url.toASCIIString());
+ s.setString(i++, type.name());
s.setString(i, displayName.toNull());
s.executeUpdate();
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
index 713982f..680e593 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java
@@ -26,10 +26,10 @@ public class JenkinsImporter {
HashSet<JenkinsServerDto> servers = new HashSet<>();
- ObjectManager<JenkinsServerDto, ActorRef<JenkinsServer>> serverManager = new ObjectManager<>("JenkinsServerOld", servers, new ObjectFactory<JenkinsServerDto, ActorRef<JenkinsServer>>() {
- public ActorRef<JenkinsServer> create(JenkinsServerDto server) {
+ ObjectManager<JenkinsServerDto, ActorRef<JenkinsServerActor>> serverManager = new ObjectManager<>("JenkinsServerOld", servers, new ObjectFactory<JenkinsServerDto, ActorRef<JenkinsServerActor>>() {
+ public ActorRef<JenkinsServerActor> create(JenkinsServerDto server) {
String name = "Jenkins: " + server.url;
- return threadedActor(name, config.jenkinsUpdateInterval, boneCp, name, new JenkinsServer(jenkinsClient, server));
+ return threadedActor(name, config.jenkinsUpdateInterval, boneCp, name, new JenkinsServerActor(jenkinsClient, server));
}
});
diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java
index 089c7d0..fa30f14 100644..100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServer.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsServerActor.java
@@ -12,12 +12,12 @@ import java.util.*;
import static io.trygvis.esper.testing.jenkins.JenkinsClient.*;
import static java.lang.System.*;
-public class JenkinsServer implements TransactionalActor {
- private static final Logger logger = LoggerFactory.getLogger(JenkinsServer.class);
+public class JenkinsServerActor implements TransactionalActor {
+ private static final Logger logger = LoggerFactory.getLogger(JenkinsServerActor.class);
private final JenkinsClient client;
public final JenkinsServerDto server;
- public JenkinsServer(JenkinsClient client, JenkinsServerDto server) {
+ public JenkinsServerActor(JenkinsClient client, JenkinsServerDto server) {
this.client = client;
this.server = server;
}
@@ -42,7 +42,7 @@ public class JenkinsServer implements TransactionalActor {
Option<JenkinsBuildDto> o = dao.selectBuildByEntryId(entry.id);
if (o.isSome()) {
- logger.debug("Old event: " + entry.id);
+ logger.debug("Old build: " + entry.id);
continue;
}
@@ -75,7 +75,7 @@ public class JenkinsServer implements TransactionalActor {
JenkinsJobXml xml = jobXmlOption.some();
- job = dao.insertJob(server.uuid, xml.url, xml.displayName);
+ job = dao.insertJob(server.uuid, xml.url, xml.type, xml.displayName);
logger.info("New job: " + xml.displayName.orSome(xml.url.toASCIIString()) + ", uuid=" + job);
}
@@ -91,40 +91,25 @@ public class JenkinsServer implements TransactionalActor {
build.duration,
build.timestamp);
- logger.info("Build inserted: " + uuid + ", i=" + i);
+ logger.info("Build inserted: " + uuid + ", item #" + i + "/" + list.size());
}
long end = currentTimeMillis();
- logger.info("Inserted " + i + " new builds in " + (end - start) + "ms.");
+ logger.info("Inserted " + i + " of " + list.size() + " builds in " + (end - start) + "ms.");
}
/**
* This sucks, a build should really include the URL to the job.
*/
public static URI createJobUrl(String u) {
- if (u.matches(".*/[-_a-zA-Z]*=.*/[0-9]*/")) {
- u = u.substring(0, u.lastIndexOf("/"));
- u = u.substring(0, u.lastIndexOf("/"));
- u = u.substring(0, u.lastIndexOf("/") + 1);
-
- return URI.create(u);
+ if (!u.matches(".*/[0-9]*/")) {
+ throw new RuntimeException("Not a valid build url: " + u);
}
- if (u.matches(".*/[.-_a-zA-Z]*\\$.*/[0-9]*/")) {
- u = u.substring(0, u.lastIndexOf("/"));
- u = u.substring(0, u.lastIndexOf("/"));
- u = u.substring(0, u.lastIndexOf("/") + 1);
-
- return URI.create(u);
- }
-
- if (u.endsWith("/")) {
- u = u.substring(0, u.length() - 1);
- }
- int i = u.lastIndexOf("/");
- u = u.substring(0, i);
+ u = u.substring(0, u.lastIndexOf("/"));
+ u = u.substring(0, u.lastIndexOf("/") + 1);
- return URI.create(u + "/");
+ return URI.create(u);
}
}