Sha256: e4bb3107a94b52177de3b986054afad34babc662efb7eeb5f0145c4df953be25

Contents?: true

Size: 721 Bytes

Versions: 52

Compression:

Stored size: 721 Bytes

Contents

require 'open-uri'
require 'json'
require 'dply/helper'

module Dply
  class Jenkins

    include Helper

    def initialize(url, project)
      @url = URI.parse(url)
      @project = project
      validate
    end

    def latest_successful_revision
      api_url = "#{@url}/job/#{@project}/api/json"
      logger.debug "using jenkins api \"#{api_url}\""
      open(api_url) do |f|
        json = JSON.parse(f.read)
        revision = json["lastSuccessfulBuild"]["number"]
        logger.debug "got revision #{revision}"
        revision
      end
    end

    def validate
      raise "invalid uri " if not ["http", "https"].include? @url.scheme
      raise "project name not defined" if not @project
    end
  end
end

Version data entries

52 entries across 52 versions & 1 rubygems

Version Path
dply-0.3.15 lib/dply/jenkins.rb
dply-0.3.14 lib/dply/jenkins.rb
dply-0.3.13 lib/dply/jenkins.rb
dply-0.3.12 lib/dply/jenkins.rb
dply-0.3.11 lib/dply/jenkins.rb
dply-0.3.10 lib/dply/jenkins.rb
dply-0.3.9 lib/dply/jenkins.rb
dply-0.3.8 lib/dply/jenkins.rb
dply-0.3.7 lib/dply/jenkins.rb
dply-0.3.6 lib/dply/jenkins.rb
dply-0.3.5 lib/dply/jenkins.rb
dply-0.3.4 lib/dply/jenkins.rb
dply-0.3.3 lib/dply/jenkins.rb
dply-0.3.2 lib/dply/jenkins.rb
dply-0.3.1 lib/dply/jenkins.rb
dply-0.3.0 lib/dply/jenkins.rb
dply-0.2.19 lib/dply/jenkins.rb
dply-0.2.18 lib/dply/jenkins.rb
dply-0.2.17 lib/dply/jenkins.rb
dply-0.2.16 lib/dply/jenkins.rb