Sha256: b37f29f238a2fff2b9346d8c927176bcdf608386dc4fe68410c2ca414326d2dc

Contents?: true

Size: 1.55 KB

Versions: 124

Compression:

Stored size: 1.55 KB

Contents

require 'travis/client'

module Travis
  module Client
    class Job < Entity
      include States, Restartable
      preloadable

      # @!parse attr_reader :repository_id, :build_id, :commit_id, :log_id, :number, :config, :state, :started_at, :finished_at, :queue, :allow_failure, :tags
      attributes :repository_id, :build_id, :commit_id, :log_id, :number, :config, :state, :started_at, :finished_at, :queue, :allow_failure, :tags, :annotation_ids
      time :started_at, :finished_at

      alias allow_failure? allow_failure

      # @!parse attr_reader :commit, :repository, :build, :annotations
      has :commit, :repository, :build, :log, :annotations

      one :job
      many :jobs

      def pull_request?
        build.pull_request?
      end

      def push?
        build.push?
      end

      def branch_info
        build.branch_info
      end

      def allow_failures?
        return false unless config.include? 'matrix' and config['matrix'].include? 'allow_failures'
        config['matrix']['allow_failures'].any? do |allow|
          allow.all? { |key, value| config[key] == value }
        end
      end

      def duration
        attributes['duration'] ||= begin
          start  = started_at  || Time.now
          finish = finished_at || Time.now
          (finish - start).to_i
        end
      end

      def delete_log(reason = {})
        log.delete_body(reason)
      end

      def pusher_channels
        build.pusher_channels + ["job-#{id}"]
      end

      def inspect_info
        "#{repository.slug}##{number}"
      end
    end
  end
end

Version data entries

124 entries across 124 versions & 2 rubygems

Version Path
travis-1.7.6.travis.672.5 lib/travis/client/job.rb
travis-1.7.6.travis.671.5 lib/travis/client/job.rb
travis-1.7.5 lib/travis/client/job.rb
travis-1.7.5.travis.658.5 lib/travis/client/job.rb
travis-1.7.5.travis.656.5 lib/travis/client/job.rb
travis-1.7.4 lib/travis/client/job.rb
travis-1.7.4.travis.654.5 lib/travis/client/job.rb
travis-1.7.3 lib/travis/client/job.rb
travis-1.7.3.travis.653.5 lib/travis/client/job.rb
travis-1.7.3.travis.651.5 lib/travis/client/job.rb
travis-1.7.3.travis.650.5 lib/travis/client/job.rb
travis-1.7.3.travis.649.5 lib/travis/client/job.rb
travis-1.7.3.travis.647.5 lib/travis/client/job.rb
travis-1.7.3.travis.646.5 lib/travis/client/job.rb
travis-1.7.3.travis.644.5 lib/travis/client/job.rb
travis-1.7.3.travis.641.5 lib/travis/client/job.rb
travis-1.7.3.travis.640.5 lib/travis/client/job.rb
travis-1.7.3.travis.637.5 lib/travis/client/job.rb
travis-1.7.2 lib/travis/client/job.rb
travis-1.7.2.travis.636.5 lib/travis/client/job.rb