class GitMaintain::TravisCI

Constants

TRAVIS_URL

Public Class Methods

new(repo) click to toggle source
Calls superclass method GitMaintain::CI::new
# File lib/travis.rb, line 5
def initialize(repo)
    super(repo)
    @url = TRAVIS_URL
end

Public Instance Methods

checkStableState(br, sha1) click to toggle source
# File lib/travis.rb, line 67
def checkStableState(br, sha1)
    return checkState(sha1, getBrStableJson())
end
checkValidState(br, sha1) click to toggle source
# File lib/travis.rb, line 54
def checkValidState(br, sha1)
    return checkState(sha1, getBrValidJson())
end
getStableLog(br, sha1) click to toggle source
# File lib/travis.rb, line 70
def getStableLog(br, sha1)
    return getLog(sha1, getBrStableJson())
end
getStableState(br, sha1) click to toggle source
# File lib/travis.rb, line 64
def getStableState(br, sha1)
    return getState(sha1, getBrStableJson())
end
getStableTS(br, sha1) click to toggle source
# File lib/travis.rb, line 73
def getStableTS(br, sha1)
    return getTS(sha1, getBrStableJson())
end
getValidLog(br, sha1) click to toggle source
# File lib/travis.rb, line 57
def getValidLog(br, sha1)
    return getLog(sha1, getBrValidJson())
end
getValidState(br, sha1) click to toggle source
# File lib/travis.rb, line 51
def getValidState(br, sha1)
    return getState(sha1, getBrValidJson())
end
getValidTS(br, sha1) click to toggle source
# File lib/travis.rb, line 60
def getValidTS(br, sha1)
    return getTS(sha1, getBrValidJson())
end
isErrored(br, status) click to toggle source
# File lib/travis.rb, line 76
def isErrored(br, status)
    return status == "failed" || status == "errored"
end

Private Instance Methods

checkState(sha1, resp) click to toggle source
# File lib/travis.rb, line 28
def checkState(sha1, resp)
    return getState(sha1, resp) == "passed"
end
findBranch(sha1, resp) click to toggle source
# File lib/travis.rb, line 38
def findBranch(sha1, resp)
    log(:DEBUG_CI, "Looking for build for #{sha1}")
    resp["branches"].each(){|br|
        commit=resp["commits"].select(){|e| e["id"] == br["commit_id"]}.first()
        raise("Incomplete JSON received from Travis") if commit == nil
        log(:DEBUG_CI, "Found entry for sha #{commit["sha"]}")
        next if commit["sha"] != sha1
        return br
    }
    return nil
end
getBrStableJson() click to toggle source
# File lib/travis.rb, line 35
def getBrStableJson()
    return getJson(@url, :travis_br_stable, 'repos/' + @repo.remote_stable + '/branches')
end
getBrValidJson() click to toggle source
# File lib/travis.rb, line 32
def getBrValidJson()
    return getJson(@url, :travis_br_valid, 'repos/' + @repo.remote_valid + '/branches')
end
getLog(sha1, resp) click to toggle source
# File lib/travis.rb, line 17
def getLog(sha1, resp)
    br = findBranch(sha1, resp)
    raise("Travis build not found") if br == nil
    job_id = br["job_ids"].last().to_s()
    return getJson(@url, "travis_log_" + job_id, 'jobs/' + job_id + '/log', false)
end
getState(sha1, resp) click to toggle source
# File lib/travis.rb, line 11
def getState(sha1, resp)
    br = findBranch(sha1, resp)
    return "not found" if br == nil

    return br["state"]
end
getTS(sha1, resp) click to toggle source
# File lib/travis.rb, line 23
def getTS(sha1, resp)
    br = findBranch(sha1, resp)
    raise("Travis build not found") if br == nil
    return br["started_at"]
end