From 813904f035b612a9c61caba97d54f8a803f5a69c Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Tue, 22 Jan 2013 09:57:54 +0100 Subject: o Showing links to the Jenkins build on the build page. --- .../esper/testing/web/resource/CoreResource.java | 9 ++++++-- .../testing/web/resource/JenkinsResource.java | 18 +++++++++------- .../resources/webapp/apps/frontPageApp/build.html | 24 +++++++++++++++++++--- .../webapp/apps/frontPageApp/frontPageApp.js | 8 ++++---- 4 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java b/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java index 8ca2521..5b0619a 100755 --- a/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java +++ b/src/main/java/io/trygvis/esper/testing/web/resource/CoreResource.java @@ -206,7 +206,8 @@ public class CoreResource extends AbstractResource { protected final SqlF getBuildJson = new SqlF() { public BuildJson apply(BuildDto dto) throws SQLException { - return new BuildJson(dto.uuid, dto.createdDate, dto.timestamp, dto.success); + return new BuildJson(dto.uuid, dto.createdDate, dto.timestamp, dto.success, "jenkins", + dto.ref.uuid); } }; @@ -252,12 +253,16 @@ class BuildJson { public final DateTime createdDate; public final DateTime timestamp; public final boolean success; + public final String serverType; + public final UUID buildUuid; - public BuildJson(UUID uuid, DateTime createdDate, DateTime timestamp, boolean success) { + BuildJson(UUID uuid, DateTime createdDate, DateTime timestamp, boolean success, String serverType, UUID buildUuid) { this.uuid = uuid; this.createdDate = createdDate; this.timestamp = timestamp; this.success = success; + this.serverType = serverType; + this.buildUuid = buildUuid; } } 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 a6d8e8e..ff6b085 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 @@ -84,8 +84,10 @@ public class JenkinsResource extends AbstractResource { return da.inTransaction(new JenkinsDaosCallback>() { protected List run() throws SQLException { List builds = new ArrayList<>(); - for (JenkinsBuildDto dto : daos.jenkinsDao.selectBuildByJob(job, page)) { - builds.add(getJenkinsBuildJson.apply(dto)); + if(job != null) { + for (JenkinsBuildDto dto : daos.jenkinsDao.selectBuildByJob(job, page)) { + builds.add(getJenkinsBuildJson.apply(dto)); + } } return builds; } @@ -122,12 +124,12 @@ public class JenkinsResource extends AbstractResource { } } - abstract class JenkinsDaosCallback implements DatabaseAccess.DaosCallback { + public static abstract class JenkinsDaosCallback implements DatabaseAccess.DaosCallback { protected Daos daos; protected abstract T run() throws SQLException; - private final XmlParser xmlParser = new XmlParser(); + private static final XmlParser xmlParser = new XmlParser(); public T run(Daos daos) throws SQLException { this.daos = daos; @@ -168,13 +170,13 @@ public class JenkinsResource extends AbstractResource { bind(JenkinsBuildXml.parse); if(xmlO.isNone()) { - return new JenkinsBuildJson(dto.uuid, dto.createdDate, new DateTime(dto.createdDate), + return new JenkinsBuildJson(dto.uuid, dto.createdDate, dto.job, new DateTime(dto.createdDate), "unknown", 0, 0); } JenkinsBuildXml xml = xmlO.some(); - return new JenkinsBuildJson(dto.uuid, dto.createdDate, new DateTime(xml.timestamp), + return new JenkinsBuildJson(dto.uuid, dto.createdDate, dto.job, new DateTime(xml.timestamp), xml.result.orSome("unknown"), xml.number, xml.duration); } }; @@ -248,14 +250,16 @@ class JenkinsJobDetailJson { class JenkinsBuildJson { public final UUID uuid; public final DateTime createdDate; + public final UUID job; public final DateTime timestamp; public final String result; public final int number; public final int duration; - JenkinsBuildJson(UUID uuid, DateTime createdDate, DateTime timestamp, String result, int number, int duration) { + JenkinsBuildJson(UUID uuid, DateTime createdDate, UUID job, DateTime timestamp, String result, int number, int duration) { this.uuid = uuid; this.createdDate = createdDate; + this.job = job; this.timestamp = timestamp; this.result = result; this.number = number; diff --git a/src/main/resources/webapp/apps/frontPageApp/build.html b/src/main/resources/webapp/apps/frontPageApp/build.html index 0972758..9fa0991 100755 --- a/src/main/resources/webapp/apps/frontPageApp/build.html +++ b/src/main/resources/webapp/apps/frontPageApp/build.html @@ -12,17 +12,35 @@ Type - Jenkins + + + Loading... + + + + Jenkins + + visit build + + + Unknown server type. + + + - Duration + Timestamp {{build.build.timestamp | date:'medium'}} + + Result + {{{true: 'SUCCESS', false: 'FAILURE'}[build.build.success]}} +

Participants

- + diff --git a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js index 1004c6f..4633892 100755 --- a/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js +++ b/src/main/resources/webapp/apps/frontPageApp/frontPageApp.js @@ -1,6 +1,6 @@ 'use strict'; -var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'jenkinsUser', 'pagingTableService', 'core.directives']).config(function ($routeProvider) { +var frontPageApp = angular.module('frontPageApp', ['ngGrid', 'person', 'badge', 'build', 'jenkinsUser', 'jenkinsBuild', 'pagingTableService', 'core.directives']).config(function ($routeProvider) { $routeProvider. when('/', {controller: FrontPageCtrl, templateUrl: '/apps/frontPageApp/frontPage.html?noCache=' + noCache}). when('/badge/', {controller: BadgeListCtrl, templateUrl: '/apps/frontPageApp/badgeList.html?noCache=' + noCache}). @@ -136,10 +136,10 @@ function BuildListCtrl($scope, Build, PagingTableService) { { count: 100, watcher: watcher }); } -function BuildCtrl($scope, $routeParams, Build, PagingTableService) { +function BuildCtrl($scope, $routeParams, Build, JenkinsBuild) { var buildUuid = $routeParams.buildUuid; - Build.get({uuid: buildUuid}, function (build) { - $scope.build = build; + $scope.build = Build.get({uuid: buildUuid}, function (build) { + $scope.jenkinsBuild = JenkinsBuild.get({uuid: build.build.buildUuid}); }); } -- cgit v1.2.3