Sha256: 611eddbbf6954fa7e2914485af73a62bbb2fd7f540d1fc692c111652a11bcca1

Contents?: true

Size: 1.59 KB

Versions: 68

Compression:

Stored size: 1.59 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'pwn'
require 'optparse'

opts = {}
OptionParser.new do |options|
  options.banner = "USAGE:
    #{File.basename($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', '<Required - Jenkins API Key>') do |api_key|
    opts[:api_key] = api_key
  end

  options.on('-vVIEW', '--view-name=VIEW', '<Required - View Name to Create>') do |view_name|
    opts[:view_name] = view_name
  end

  options.on('-rREGX', '--regx-filter=REGEX', '<Required - RegEx >') do |regex_filter|
    opts[:regex_filter] = regex_filter
  end
end.parse!

if opts.empty?
  puts `#{File.basename($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]
view_name = opts[:view_name].to_s.chomp.strip.scrub
regex_filter = opts[:regex_filter].to_s.chomp.strip.scrub

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.view.create_list_view(
  name: view_name,
  regex: regex_filter
)

PWN::Plugins::Jenkins.disconnect(jenkins_obj: jenkins_obj)

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
pwn-0.5.235 bin/pwn_jenkins_create_view
pwn-0.5.234 bin/pwn_jenkins_create_view
pwn-0.5.233 bin/pwn_jenkins_create_view
pwn-0.5.232 bin/pwn_jenkins_create_view
pwn-0.5.231 bin/pwn_jenkins_create_view
pwn-0.5.230 bin/pwn_jenkins_create_view
pwn-0.5.229 bin/pwn_jenkins_create_view
pwn-0.5.228 bin/pwn_jenkins_create_view
pwn-0.5.227 bin/pwn_jenkins_create_view
pwn-0.5.226 bin/pwn_jenkins_create_view
pwn-0.5.225 bin/pwn_jenkins_create_view
pwn-0.5.224 bin/pwn_jenkins_create_view
pwn-0.5.223 bin/pwn_jenkins_create_view
pwn-0.5.222 bin/pwn_jenkins_create_view
pwn-0.5.221 bin/pwn_jenkins_create_view
pwn-0.5.220 bin/pwn_jenkins_create_view
pwn-0.5.219 bin/pwn_jenkins_create_view
pwn-0.5.217 bin/pwn_jenkins_create_view
pwn-0.5.216 bin/pwn_jenkins_create_view
pwn-0.5.215 bin/pwn_jenkins_create_view