Sha256: a2e976e134c9353b76172767bca917797859d9d6319c7a0a7abb4db3519a44cb

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# encoding: utf-8

require 'jenkins_api_client'

module Napkin
  class CLI < Thor
    class Jenkins < Thor
      include Thor::Actions

      desc 'build JOB', 'run the jenkins JOB'
      method_option :params,
                    :aliases  => '-p',
                    :default  => {},
                    :desc     => 'Set the build parameters',
                    :required => false,
                    :type     => :hash
      def build(job)
        client.job.build(job, options[:params])
        say "#{job} building.", :green
      rescue JenkinsApi::Exceptions::NotFound
        say "#{job} not found.", :red
      rescue JenkinsApi::Exceptions::ApiException
        say "#{job} failed to start. Did you forget something maybe?", :red
      end

      private

      def client
        @client ||= JenkinsApi::Client.new(
          :server_url => ENV['JENKINS_SERVER_URL'],
          :username   => ENV['JENKINS_USERNAME'],
          :password   => ENV['JENKINS_PASSWORD'],
          :log_level  => ENV['DEBUG'] ? Logger::DEBUG : Logger::INFO
        )
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
napkin-0.0.6 lib/napkin/cli/jenkins.rb
napkin-0.0.5 lib/napkin/cli/jenkins.rb