Sha256: 38ad258633594826074c5862cf461cba73bdb66ed5c53b71c63250c9ea5d2719

Contents?: true

Size: 919 Bytes

Versions: 2

Compression:

Stored size: 919 Bytes

Contents

require 'jenkins_api_client'
module Jenkinson
  class API
    attr_reader :client

    def initialize(config)
      @client = JenkinsApi::Client.new(config)
    end

    def create_or_update_jobs(jobs)
      jobs.each do |job|
        File.open(job, "rb") do |xml_file|
          jobname = File.basename( job, ".*")
          client.job.create_or_update(jobname, xml_file.read)
        end
      end
    end
  
    def get_jobs_config(target_dir)
      client.job.list_all.each do |jobname|
        job_on_server = client.job.get_config(jobname) rescue nil
        job = "#{target_dir}/#{jobname}.xml"
        next if job_on_server.nil?
        File.open(job, "w") do |xml_file|
          xml_file << job_on_server
        end
      end
    end

    def install_plugins(plugins_str)
      plugins = plugins_str.split(',')
      plugins.each do |plugin|
        client.plugin.install(plugin)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jenkinson-0.0.2 lib/jenkinson/api.rb
jenkinson-0.0.1 lib/jenkinson/api.rb