Sha256: 887ab06a1ea0b0304e1ca30094136bf47a20a6f8554e484e9e7baae65060ca99

Contents?: true

Size: 1.06 KB

Versions: 8

Compression:

Stored size: 1.06 KB

Contents

require 'jenkins_api_client'

module Lhj
  class Command
    class JenkinsBuild < Command
      self.summary = '执行jenkins的build任务'

      self.arguments = [
        CLAide::Argument.new('--server_url=http://www.jenkins.com', true),
        CLAide::Argument.new('--job=job1', true)
      ]

      def self.options
        [
          %w[--server_url jenkins的地址],
          %w[--job 运行的任务名]
        ]
      end

      def validate!
        super
        help! '输入jenkins的地址' unless @server_url
        help! '输入任务名' unless @job
      end

      def initialize(argv)
        @server_url = argv.option('server_url')
        @job = argv.option('job')
        super
      end

      def handle
        client = JenkinsApi::Client.new(server_ip: '47.97.61.232', server_port: 8080, username: 'aomi', password: '11e5ddb4c71a61abf66ed0ab4c08090794')
        # puts client.user.get('aomi')
        # puts client.job.list_all
        # client.job.build('aomi_uat')
        puts client.job.get_console_output('aomi_uat', 253)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
lhj-tools-0.2.21 lib/lhj/command/jenkins/jenkins_build.rb
lhj-tools-0.2.20 lib/lhj/command/jenkins/jenkins_build.rb
lhj-tools-0.2.19 lib/lhj/command/jenkins/jenkins_build.rb
lhj-tools-0.2.18 lib/lhj/command/jenkins/jenkins_build.rb
lhj-tools-0.2.17 lib/lhj/command/jenkins/jenkins_build.rb
lhj-tools-0.2.16 lib/lhj/command/jenkins/jenkins_build.rb
lhj-tools-0.2.15 lib/lhj/command/jenkins/jenkins_build.rb
lhj-tools-0.2.14 lib/lhj/command/jenkins/jenkins_build.rb