class Autoproj::CLI::MainJenkins

The ‘jenkins’ subcommand for autoproj

Public Instance Methods

create_ops(url, target_os: nil) click to toggle source
# File lib/autoproj/cli/main_jenkins.rb, line 21
def create_ops(url, target_os: nil)
    if username = options[:username]
        password = options[:password] || request_password
        auth = Hash[username: username,
                    password: password]
    elsif options[:password]
        raise ArgumentError, "--password given without --username"
    else
        auth = Hash.new
    end

    workspace_options = Hash.new
    if target_os
        names, versions =  target_os.split(':')
        names = names.split(',')
        names << 'default'
        versions = versions.split(',')
        versions << 'default'
        workspace_options[:os_package_resolver] = OSPackageResolver.new(operating_system: [names, versions])
    end
    ws = Autoproj::Workspace.default(**workspace_options)

    STDERR.puts "connecting to jenkins '#{url}' with prefix '#{options[:prefix]}'"
    Jenkins.new(ws,
                job_prefix: options[:job_prefix],
                server_url: url,
                **auth)
end
init(url, *package_names) click to toggle source
# File lib/autoproj/cli/main_jenkins.rb, line 64
def init(url, *package_names)
    require 'autoproj/cli/jenkins'
    ops = create_ops(url, target_os: options[:target_os])

    if options[:seed]
        seed = File.read(options[:seed])
    end

    ops.create_or_update_buildconf_job(
        *package_names,
        seed: seed,
        credentials_id: options[:credentials_id],
        vcs_credentials: options[:vcs_credentials],
        dev: options[:dev])
    if options[:trigger]
        ops.trigger_buildconf_job
    end
end
postprocess_tests(output_dir, *package_names) click to toggle source
# File lib/autoproj/cli/main_jenkins.rb, line 111
def postprocess_tests(output_dir, *package_names)
    require 'autoproj/cli/test_postprocessing'
    ops = TestPostprocessing.new(Workspace.default)
    if options[:after]
        reference_time = File.stat(options[:after]).mtime
    end
    ops.process(output_dir, *package_names, after: reference_time)
end
relativize(root_dir, input_text, output_text) click to toggle source
# File lib/autoproj/cli/main_jenkins.rb, line 122
def relativize(root_dir, input_text, output_text)
    require 'autoproj/jenkins'
    relativize = Autoproj::Jenkins::Relativize.new(Pathname.new(root_dir), input_text, output_text)
    processed_paths = relativize.process
    puts "modified #{processed_paths.size} file"
    processed_paths.each do |p|
        puts "  #{p}"
    end
end
request_password() click to toggle source
# File lib/autoproj/cli/main_jenkins.rb, line 13
def request_password
    STDOUT.print "Password: "
    STDOUT.flush
    STDIN.noecho do |io|
        io.readline.chomp
    end
end
update(url, *package_names) click to toggle source
# File lib/autoproj/cli/main_jenkins.rb, line 91
def update(url, *package_names)
    require 'autoproj/cli/jenkins'

    if options[:seed]
        seed = File.read(options[:seed])
    end

    ops = create_ops(url)
    Autoproj.report(silent: !options[:debug], debug: options[:debug]) do
        updated_jobs = ops.add_or_update_packages(*package_names, seed: seed, dev: options[:dev], vcs_credentials: options[:vcs_credentials])
        updated_jobs.sort.each do |job_name|
            puts job_name
        end
    end
end