Wait for job.id in Travis.Artifact

This commit is contained in:
Piotr Sarnacki 2013-01-29 15:34:58 +01:00
parent 5687f57388
commit 9df79d6944

View File

@ -8,6 +8,7 @@ require 'travis/model'
init: -> init: ->
@_super.apply this, arguments @_super.apply this, arguments
@addObserver 'job.id', @fetchBody
@fetchBody() @fetchBody()
@set 'queue', Ember.A([]) @set 'queue', Ember.A([])
@ -21,25 +22,28 @@ require 'travis/model'
@incrementProperty('version') @incrementProperty('version')
fetchBody: -> fetchBody: ->
self = this if jobId = @get('job.id')
Travis.ajax.ajax "/jobs/#{@get('job.id')}/log.txt?cors_hax=true", 'GET', @removeObserver 'job.id', @fetchBody
dataType: 'text'
contentType: 'text/plain'
success: (data, textStatus, xhr) ->
if xhr.status == 204
logUrl = xhr.getResponseHeader('X-Log-Location')
# For some reason not all browsers can fetch this header self = this
unless logUrl Travis.ajax.ajax "/jobs/#{jobId}/log.txt?cors_hax=true", 'GET',
logUrl = self.s3Url("/jobs/#{self.get('job.id')}/log.txt") dataType: 'text'
contentType: 'text/plain'
success: (data, textStatus, xhr) ->
if xhr.status == 204
logUrl = xhr.getResponseHeader('X-Log-Location')
$.ajax # For some reason not all browsers can fetch this header
url: logUrl unless logUrl
type: 'GET' logUrl = self.s3Url("/jobs/#{jobId}/log.txt")
success: (data) ->
self.fetchedBody(data) $.ajax
else url: logUrl
self.fetchedBody(data) type: 'GET'
success: (data) ->
self.fetchedBody(data)
else
self.fetchedBody(data)
s3Url: (path) -> s3Url: (path) ->
endpoint = Travis.config.api_endpoint endpoint = Travis.config.api_endpoint