aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java15
-rwxr-xr-xsrc/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java102
-rw-r--r--src/main/webapp/apps/jenkinsApp/build.html41
-rw-r--r--src/main/webapp/apps/jenkinsApp/jenkinsApp.js22
-rwxr-xr-xsrc/main/webapp/apps/jenkinsApp/job.html4
5 files changed, 149 insertions, 35 deletions
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 ee793fa..0ed0d5f 100755
--- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
+++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsDao.java
@@ -180,6 +180,14 @@ public class JenkinsDao {
}
}
+ public SqlOption<JenkinsBuildDto> selectBuild(UUID uuid) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("SELECT " + JENKINS_BUILD + " FROM jenkins_build WHERE uuid=?")) {
+ int i = 1;
+ s.setString(i, uuid.toString());
+ return fromRs(s.executeQuery()).map(jenkinsBuild);
+ }
+ }
+
public int selectBuildCountByJob(UUID job) throws SQLException {
try (PreparedStatement s = c.prepareStatement("SELECT count(1) FROM jenkins_build WHERE job=?")) {
int i = 1;
@@ -223,11 +231,10 @@ public class JenkinsDao {
}
}
- public SqlOption<JenkinsUserDto> selectUser(UUID uuid, UUID server) throws SQLException {
- try (PreparedStatement s = c.prepareStatement("SELECT " + JENKINS_USER + " FROM jenkins_user WHERE uuid=? AND server=?")) {
+ public SqlOption<JenkinsUserDto> selectUser(UUID uuid) throws SQLException {
+ try (PreparedStatement s = c.prepareStatement("SELECT " + JENKINS_USER + " FROM jenkins_user WHERE uuid=?")) {
int i = 1;
- s.setString(i++, uuid.toString());
- s.setString(i, server.toString());
+ s.setString(i, uuid.toString());
return fromRs(s.executeQuery()).map(jenkinsUser);
}
}
diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java b/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java
index aab108b..bd0c613 100755
--- a/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java
+++ b/src/main/java/io/trygvis/esper/testing/web/resource/JenkinsResource.java
@@ -1,7 +1,5 @@
package io.trygvis.esper.testing.web.resource;
-import fj.*;
-import fj.data.*;
import io.trygvis.esper.testing.*;
import io.trygvis.esper.testing.jenkins.*;
import io.trygvis.esper.testing.jenkins.xml.*;
@@ -70,9 +68,9 @@ public class JenkinsResource extends AbstractResource {
@GET
@Path("/job/{uuid}")
@Produces(MediaType.APPLICATION_JSON)
- public JenkinsJobJson getJob(@MagicParam final UUID uuid) throws Exception {
- return sql(new JenkinsDaosCallback<SqlOption<JenkinsJobJson>>() {
- protected SqlOption<JenkinsJobJson> run() throws SQLException {
+ public JenkinsJobJsonDetail getJob(@MagicParam final UUID uuid) throws Exception {
+ return sql(new JenkinsDaosCallback<SqlOption<JenkinsJobJsonDetail>>() {
+ protected SqlOption<JenkinsJobJsonDetail> run() throws SQLException {
return daos.jenkinsDao.selectJob(uuid).map(getJenkinsJobJsonDetail);
}
});
@@ -93,6 +91,17 @@ public class JenkinsResource extends AbstractResource {
});
}
+ @GET
+ @Path("/build/{uuid}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public JenkinsBuildJsonDetail getBuild(@MagicParam final UUID build) throws Exception {
+ return sql(new JenkinsDaosCallback<SqlOption<JenkinsBuildJsonDetail>>() {
+ protected SqlOption<JenkinsBuildJsonDetail> run() throws SQLException {
+ return daos.jenkinsDao.selectBuild(build).map(getJenkinsBuildJsonDetail);
+ }
+ });
+ }
+
public static UUID parseUuid(String s) {
try {
return UUID.fromString(s);
@@ -132,24 +141,40 @@ public class JenkinsResource extends AbstractResource {
}
};
- protected SqlF<JenkinsJobDto, JenkinsJobJson> getJenkinsJobJsonDetail = new SqlF<JenkinsJobDto, JenkinsJobJson>() {
- public JenkinsJobJson apply(JenkinsJobDto job) throws SQLException {
- int buildCount = daos.jenkinsDao.selectBuildCountByJob(job.uuid);
- return new JenkinsJobJson(job.uuid, job.createdDate, job.server, job.displayName.toNull(), buildCount);
+ protected SqlF<JenkinsJobDto,JenkinsJobJsonDetail> getJenkinsJobJsonDetail = new SqlF<JenkinsJobDto, JenkinsJobJsonDetail>() {
+ public JenkinsJobJsonDetail apply(JenkinsJobDto dto) throws SQLException {
+ return new JenkinsJobJsonDetail(
+ getJenkinsJobJson.apply(dto),
+ daos.jenkinsDao.selectBuildCountByJob(dto.uuid));
}
};
protected SqlF<JenkinsBuildDto, JenkinsBuildJson> getJenkinsBuildJson = new SqlF<JenkinsBuildDto, JenkinsBuildJson>() {
public JenkinsBuildJson apply(JenkinsBuildDto dto) throws SQLException {
- Option<String> result = daos.fileDao.load(dto.file).toFj().
+ JenkinsBuildXml xml = daos.fileDao.load(dto.file).toFj().
bind(xmlParser.parseDocument).
- bind(JenkinsBuildXml.parse).map(new F<JenkinsBuildXml, String>() {
- public String f(JenkinsBuildXml xml) {
- return xml.result.orSome("unknown");
- }
- });
+ bind(JenkinsBuildXml.parse).some();
+
+ return new JenkinsBuildJson(dto.uuid, dto.createdDate, new DateTime(xml.timestamp),
+ xml.result.orSome("unknown"), xml.number, xml.duration);
+ }
+ };
+
+ protected SqlF<JenkinsBuildDto,JenkinsBuildJsonDetail> getJenkinsBuildJsonDetail = new SqlF<JenkinsBuildDto, JenkinsBuildJsonDetail>() {
+ public JenkinsBuildJsonDetail apply(JenkinsBuildDto dto) throws SQLException {
+ List<JenkinsUserJson> users = new ArrayList<>();
+ for (UUID user : dto.users) {
+ users.add(daos.jenkinsDao.selectUser(user).map(getJenkinsUserJson).get());
+ }
+ return new JenkinsBuildJsonDetail(
+ getJenkinsBuildJson.apply(dto),
+ users);
+ }
+ };
- return new JenkinsBuildJson(dto.uuid, dto.createdDate, result.orSome("unknown"));
+ protected SqlF<JenkinsUserDto,JenkinsUserJson> getJenkinsUserJson = new SqlF<JenkinsUserDto, JenkinsUserJson>() {
+ public JenkinsUserJson apply(JenkinsUserDto dto) throws SQLException {
+ return new JenkinsUserJson(dto.uuid, dto.createdDate, dto.absoluteUrl);
}
};
}
@@ -179,21 +204,20 @@ class JenkinsJobJson {
public final UUID server;
public final String displayName;
- public final Integer buildCount;
-
JenkinsJobJson(UUID uuid, DateTime createdDate, UUID server, String displayName) {
this.uuid = uuid;
this.createdDate = createdDate;
this.server = server;
this.displayName = displayName;
- this.buildCount = null;
}
+}
- JenkinsJobJson(UUID uuid, DateTime createdDate, UUID server, String displayName, int buildCount) {
- this.uuid = uuid;
- this.createdDate = createdDate;
- this.server = server;
- this.displayName = displayName;
+class JenkinsJobJsonDetail {
+ public final JenkinsJobJson job;
+ public final Integer buildCount;
+
+ JenkinsJobJsonDetail(JenkinsJobJson job, Integer buildCount) {
+ this.job = job;
this.buildCount = buildCount;
}
}
@@ -201,11 +225,39 @@ class JenkinsJobJson {
class JenkinsBuildJson {
public final UUID uuid;
public final DateTime createdDate;
+ public final DateTime timestamp;
public final String result;
+ public final int number;
+ public final int duration;
- JenkinsBuildJson(UUID uuid, DateTime createdDate, String result) {
+ JenkinsBuildJson(UUID uuid, DateTime createdDate, DateTime timestamp, String result, int number, int duration) {
this.uuid = uuid;
this.createdDate = createdDate;
+ this.timestamp = timestamp;
this.result = result;
+ this.number = number;
+ this.duration = duration;
+ }
+}
+
+class JenkinsBuildJsonDetail {
+ public final JenkinsBuildJson build;
+ public final List<JenkinsUserJson> participants;
+
+ JenkinsBuildJsonDetail(JenkinsBuildJson build, List<JenkinsUserJson> participants) {
+ this.build = build;
+ this.participants = participants;
+ }
+}
+
+class JenkinsUserJson {
+ public final UUID uuid;
+ public final DateTime createdDate;
+ public final String absoluteUrl;
+
+ JenkinsUserJson(UUID uuid, DateTime createdDate, String absoluteUrl) {
+ this.uuid = uuid;
+ this.createdDate = createdDate;
+ this.absoluteUrl = absoluteUrl;
}
}
diff --git a/src/main/webapp/apps/jenkinsApp/build.html b/src/main/webapp/apps/jenkinsApp/build.html
new file mode 100644
index 0000000..02fa60b
--- /dev/null
+++ b/src/main/webapp/apps/jenkinsApp/build.html
@@ -0,0 +1,41 @@
+<div class="container">
+
+ <div class="page-header">
+ <h1>Jenkins Build</h1>
+ </div>
+
+ <ul class="breadcrumb">
+ <li><a ng-click="showServers()">All Servers</a> <span class="divider">/</span></li>
+ <li><a ng-click="showServer()">Servers</a> <span class="divider">/</span></li>
+ <li><a ng-click="showJob()">Job</a> <span class="divider">/</span></li>
+ <li class="active">Build</li>
+ </ul>
+
+ <h3>Overview</h3>
+ <table class="table">
+ <tbody>
+ <tr>
+ <th>Timestamp</th>
+ <td>{{details.build.timestamp | date:'medium'}}</td>
+ </tr>
+ <tr>
+ <th>Number</th>
+ <td>{{details.build.number}}</td>
+ </tr>
+ <tr>
+ <th>Duration</th>
+ <td>{{details.build.duration / 1000 | number:0}}s</td>
+ </tr>
+ </tbody>
+ </table>
+
+ <h3>Users</h3>
+ <table>
+ <tbody>
+ <tr ng-repeat="user in details.participants">
+ <td>{{user.uuid}}</td>
+ </tr>
+ </tbody>
+ </table>
+
+</div>
diff --git a/src/main/webapp/apps/jenkinsApp/jenkinsApp.js b/src/main/webapp/apps/jenkinsApp/jenkinsApp.js
index 19d107d..1cd2d2a 100644
--- a/src/main/webapp/apps/jenkinsApp/jenkinsApp.js
+++ b/src/main/webapp/apps/jenkinsApp/jenkinsApp.js
@@ -4,7 +4,8 @@ var jenkinsApp = angular.module('jenkinsApp', ['jenkinsServer', 'jenkinsJob', 'j
$routeProvider.
when('/', {controller: ServerListCtrl, templateUrl: '/apps/jenkinsApp/server-list.html?noCache=' + noCache}).
when('/server/:uuid', {controller: ServerCtrl, templateUrl: '/apps/jenkinsApp/server.html?noCache=' + noCache}).
- when('/job/:uuid', {controller: JobCtrl, templateUrl: '/apps/jenkinsApp/job.html?noCache=' + noCache});
+ when('/job/:uuid', {controller: JobCtrl, templateUrl: '/apps/jenkinsApp/job.html?noCache=' + noCache}).
+ when('/build/:uuid', {controller: BuildCtrl, templateUrl: '/apps/jenkinsApp/build.html?noCache=' + noCache});
});
function ServerListCtrl($scope, $location, JenkinsServer) {
@@ -32,12 +33,25 @@ function ServerCtrl($scope, $location, $routeParams, JenkinsServer, JenkinsJob,
function JobCtrl($scope, $location, $routeParams, JenkinsJob, JenkinsBuild, PagingTableService) {
var jobUuid = $routeParams.uuid;
- JenkinsJob.get({uuid: jobUuid}, function (job) {
- $scope.job = job;
+ JenkinsJob.get({uuid: jobUuid}, function (details) {
+ $scope.details = details;
});
$scope.builds = PagingTableService.create($scope, PagingTableService.defaultCallback(JenkinsBuild, {job: jobUuid}));
$scope.showServers = function () { $location.path('/'); };
- $scope.showServer = function (uuid) { $location.path('/server/' + $scope.job.server); };
+ $scope.showServer = function () { $location.path('/server/' + $scope.job.server); };
+ $scope.showBuild = function (uuid) { $location.path('/build/' + uuid); };
+}
+
+function BuildCtrl($scope, $location, $routeParams, JenkinsBuild) {
+ var buildUuid = $routeParams.uuid;
+
+ JenkinsBuild.get({uuid: buildUuid}, function (details) {
+ $scope.details = details;
+ });
+
+ $scope.showServers = function () { $location.path('/'); };
+ $scope.showServer = function (uuid) { $location.path('/server/' + $scope.server.uuid); };
+ $scope.showJob = function (uuid) { $location.path('/job/' + $scope.build.job); };
}
diff --git a/src/main/webapp/apps/jenkinsApp/job.html b/src/main/webapp/apps/jenkinsApp/job.html
index 6ee7af0..027748a 100755
--- a/src/main/webapp/apps/jenkinsApp/job.html
+++ b/src/main/webapp/apps/jenkinsApp/job.html
@@ -16,11 +16,11 @@
<tbody>
<tr>
<th>URL</th>
- <td><a href="{{job.displayName}}">{{job.displayName}}</a></td>
+ <td><a href="{{details.job.displayName}}">{{details.job.displayName}}</a></td>
</tr>
<tr>
<th>Build count</th>
- <td>{{job.buildCount}}</td>
+ <td>{{details.buildCount}}</td>
</tr>
</tbody>
</table>