Sha256: 1a79bd9083ce1f8734b76abeb6c01b280b4d040f56e42b800a7f8037a43829d4
Contents?: true
Size: 1.55 KB
Versions: 339
Compression:
Stored size: 1.55 KB
Contents
#!/usr/bin/env ruby # frozen_string_literal: true require 'pwn' require 'optparse' opts = {} OptionParser.new do |options| options.banner = "USAGE: #{$PROGRAM_NAME} [opts] " options.on('-sIP', '--ip=IP', '<Required - Jenkins Server IP>') { |s| opts[:ip] = s } options.on('-dPORT', '--dest-port=PORT', '<Optional - Jenkins Server Port (Defaults to 8080)>') do |port| opts[:port] = port end options.on('-UUSER', '--username=USER', '<Required - Jenkins Username>') do |user| opts[:username] = user end options.on('-PKEY', '--api-key=KEY', '<Optional - Jenkins API Key (Will Prompt if Flag Undetected)>') do |api_key| opts[:api_key] = api_key end options.on('-jNAME', '--job-name=NAME', '<Required - Name of Job to Create>') do |job| opts[:job_name] = job end options.on('-cPATH', '--config-xml=PATH', '<Required - Path to config.xml>') do |xml| opts[:config_xml] = xml end end.parse! if opts.empty? puts `#{$PROGRAM_NAME} --help` exit 1 end ip = opts[:ip].to_s.scrub port = opts[:port].to_i username = opts[:username] api_key = opts[:api_key] job_name = opts[:job_name].to_s.scrub config_xml = File.read(opts[:config_xml]) if File.exist?(opts[:config_xml]) if port.positive? jenkins_obj = PWN::Plugins::Jenkins.connect( ip: ip, port: port, username: username, api_key: api_key ) else jenkins_obj = PWN::Plugins::Jenkins.connect( ip: ip, username: username, api_key: api_key ) end jenkins_obj.job.create( job_name, config_xml ) PWN::Plugins::Jenkins.disconnect(jenkins_obj: jenkins_obj)
Version data entries
339 entries across 339 versions & 1 rubygems