Sha256: 24098456d1cd389f7fea3c4a15c05059aa9c1616aa6e07e9c89a58711d85eb05

Contents?: true

Size: 1 KB

Versions: 7

Compression:

Stored size: 1 KB

Contents

class Gitmine
  class HudsonJob
    class Http
      include HTTParty

      base_uri Config.hudson_host
      basic_auth(Config.hudson_username, Config.hudson_password) if Config.hudson_username
      headers 'Content-type' => 'text/xml'
      # I get timeout errors on heroku but not on local env. Is that because of REE-1.8.7 ?
      # Workaround: Set the timeout to 10 seconds and rescue timeout errors.
      default_timeout 8
    end

    def self.all_by_name_including(pattern)
      HudsonJob.all.select { |projects| projects.name[pattern] }
    end

    def self.all
      r = Http.get('/api/xml')
      return [] unless r.code == 200
      r.parsed_response["hudson"]["job"].map do |jobs_data|
        new(jobs_data["name"])
      end
    end

    attr_accessor :name

    def initialize(name)
      @name = name
    end

    def delete!
      r = Http.post("/job/#{name}/doDelete")
      raise "Failed to delete job #{name}" unless r.code == 200
      puts green(" - #{name} deleted!")

      true
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gitmine-0.1.12 lib/gitmine/hudson_job.rb
gitmine-0.1.11 lib/gitmine/hudson_job.rb
gitmine-0.1.10 lib/gitmine/hudson_job.rb
gitmine-0.1.9 lib/gitmine/hudson_job.rb
gitmine-0.1.8 lib/gitmine/hudson_job.rb
gitmine-0.1.7 lib/gitmine/hudson_job.rb
gitmine-0.1.6 lib/gitmine/hudson_job.rb