Sha256: 5d37f1e7687364d254b02febe29607a017b4a81cfc3ade2395d9a97b2447ed63

Contents?: true

Size: 1.56 KB

Versions: 339

Compression:

Stored size: 1.56 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', '<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 `#{$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

339 entries across 339 versions & 1 rubygems

Version Path
pwn-0.5.164 bin/pwn_jenkins_create_view
pwn-0.5.163 bin/pwn_jenkins_create_view
pwn-0.5.162 bin/pwn_jenkins_create_view
pwn-0.5.161 bin/pwn_jenkins_create_view
pwn-0.5.160 bin/pwn_jenkins_create_view
pwn-0.5.159 bin/pwn_jenkins_create_view
pwn-0.5.158 bin/pwn_jenkins_create_view
pwn-0.5.157 bin/pwn_jenkins_create_view
pwn-0.5.156 bin/pwn_jenkins_create_view
pwn-0.5.155 bin/pwn_jenkins_create_view
pwn-0.5.154 bin/pwn_jenkins_create_view
pwn-0.5.153 bin/pwn_jenkins_create_view
pwn-0.5.152 bin/pwn_jenkins_create_view
pwn-0.5.151 bin/pwn_jenkins_create_view
pwn-0.5.150 bin/pwn_jenkins_create_view
pwn-0.5.106 bin/pwn_jenkins_create_view
pwn-0.5.105 bin/pwn_jenkins_create_view
pwn-0.5.104 bin/pwn_jenkins_create_view
pwn-0.5.103 bin/pwn_jenkins_create_view
pwn-0.5.102 bin/pwn_jenkins_create_view