diff --git a/data/database.py b/data/database.py index 3f76a8668..86a797bed 100644 --- a/data/database.py +++ b/data/database.py @@ -216,7 +216,7 @@ class RepositoryBuild(BaseModel): tag = CharField() phase = CharField(default='waiting') started = DateTimeField(default=datetime.now) - + display_name = CharField() class QueueItem(BaseModel): diff --git a/data/model.py b/data/model.py index 72c4e1861..dcfed0198 100644 --- a/data/model.py +++ b/data/model.py @@ -1270,9 +1270,11 @@ def list_repository_builds(namespace_name, repository_name, return fetched -def create_repository_build(repo, access_token, resource_key, tag): +def create_repository_build(repo, access_token, resource_key, tag, + display_name): return RepositoryBuild.create(repository=repo, access_token=access_token, - resource_key=resource_key, tag=tag) + resource_key=resource_key, tag=tag, + display_name=display_name) def create_webhook(repo, params_obj): diff --git a/data/userfiles.py b/data/userfiles.py index 86ddb62a2..c2a8bc63c 100644 --- a/data/userfiles.py +++ b/data/userfiles.py @@ -59,3 +59,9 @@ class UserRequestFiles(object): full_key = os.path.join(self._prefix, file_id) k = Key(self._bucket, full_key) return k.generate_url(expires_in) + + def get_file_checksum(self, file_id): + self._initialize_s3() + full_key = os.path.join(self._prefix, file_id) + k = self._bucket.lookup(full_key) + return k.etag[1:-1][:7] diff --git a/endpoints/api.py b/endpoints/api.py index de4156e25..9990327d5 100644 --- a/endpoints/api.py +++ b/endpoints/api.py @@ -1148,6 +1148,7 @@ def build_status_view(build_obj): 'id': build_obj.uuid, 'phase': build_obj.phase, 'started': build_obj.started, + 'display_name': build_obj.display_name, 'status': status, } @@ -1241,11 +1242,13 @@ def request_repo_build(namespace, repository): repo = model.get_repository(namespace, repository) token = model.create_access_token(repo, 'write') + display_name = user_files.get_file_checksum(dockerfile_id) + logger.debug('**********Md5: %s' % display_name) host = urlparse.urlparse(request.url).netloc tag = '%s/%s/%s' % (host, repo.namespace, repo.name) build_request = model.create_repository_build(repo, token, dockerfile_id, - tag) + tag, display_name) dockerfile_build_queue.put(json.dumps({ 'build_uuid': build_request.uuid, 'namespace': namespace, diff --git a/initdb.py b/initdb.py index f5001326f..cb29d5246 100644 --- a/initdb.py +++ b/initdb.py @@ -277,7 +277,8 @@ def populate_database(): token = model.create_access_token(building, 'write') tag = 'ci.devtable.com:5000/%s/%s' % (building.namespace, building.name) - build = model.create_repository_build(building, token, '123-45-6789', tag) + build = model.create_repository_build(building, token, '123-45-6789', tag, + 'build-name') build.uuid = 'deadbeef-dead-beef-dead-beefdeadbeef' build.save() diff --git a/static/js/controllers.js b/static/js/controllers.js index 65bf2e652..0f8682c91 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -668,11 +668,6 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope $('.build-logs').height($(window).height() - 365); }; - $scope.getShortId = function(id) { - var lastIndex = id.lastIndexOf('-'); - return id.substr(lastIndex + 1); - }; - $scope.getCommandKind = function(fullTitle) { var colon = fullTitle.indexOf(':'); var title = getTitleWithoutStep(fullTitle); diff --git a/static/partials/repo-build.html b/static/partials/repo-build.html index 3f4759b42..828ce5797 100644 --- a/static/partials/repo-build.html +++ b/static/partials/repo-build.html @@ -19,7 +19,7 @@