Class: Autoproj::CLI::Jenkins

Inherits:
InspectionTool
  • Object
show all
Defined in:
lib/autoproj/cli/jenkins.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ws, job_prefix: '', **options) ⇒ Jenkins

Returns a new instance of Jenkins.



10
11
12
13
14
# File 'lib/autoproj/cli/jenkins.rb', line 10

def initialize(ws, job_prefix: '', **options)
    super(ws)
    @server = Autoproj::Jenkins::Server.new(**options)
    @updater = Autoproj::Jenkins::Updater.new(ws, server, job_prefix: job_prefix)
end

Instance Attribute Details

#serverObject (readonly)

Returns the value of attribute server.



7
8
9
# File 'lib/autoproj/cli/jenkins.rb', line 7

def server
  @server
end

#updaterObject (readonly)

Returns the value of attribute updater.



8
9
10
# File 'lib/autoproj/cli/jenkins.rb', line 8

def updater
  @updater
end

Instance Method Details

#add_or_update_packages(*package_names, seed: nil, dev: false, vcs_credentials: []) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/autoproj/cli/jenkins.rb', line 47

def add_or_update_packages(*package_names, seed: nil, dev: false, vcs_credentials: [])
    initialize_and_load
    source_packages, _ = finalize_setup(package_names, non_imported_packages: :ignore, auto_exclude: true)
    source_packages = source_packages.map do |package_name|
        ws.manifest.package_definition_by_name(package_name)
    end

    if dev
        gemfile = 'buildconf-vagrant-Gemfile'
        autoproj_install_path = '/opt/autoproj/bin/autoproj_install'
    else
        gemfile = 'buildconf-Gemfile'
        autoproj_install_path = nil
    end

    updater.update(
        *source_packages,
        seed: seed,
        gemfile: gemfile,
        autoproj_install_path: autoproj_install_path,
        vcs_credentials: parse_vcs_credentials(vcs_credentials))
end

#create_or_update_buildconf_job(*package_names, seed: nil, dev: false, credentials_id: nil, vcs_credentials: []) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/autoproj/cli/jenkins.rb', line 25

def create_or_update_buildconf_job(*package_names, seed: nil, dev: false, credentials_id: nil, vcs_credentials: [])
    initialize_and_load

    if dev
        gemfile = 'buildconf-vagrant-Gemfile'
        autoproj_install_path = '/opt/autoproj/bin/autoproj_install'
    else
        gemfile = 'buildconf-Gemfile'
        autoproj_install_path = nil
    end

    # Must NOT resolve the package names into packages. If they are
    # package sets/metapackages, they need to be provided as-is to
    # the buildconf template, so that the metapackage gets resolved
    # each time instead of only at the point 'jenkins init' was done
    updater.create_or_update_buildconf_job(*package_names, gemfile: gemfile,
                                           seed: seed,
                                           autoproj_install_path: autoproj_install_path, dev: dev,
                                           credentials_id: credentials_id,
                                           vcs_credentials: parse_vcs_credentials(vcs_credentials))
end

#parse_vcs_credentials(credentials) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/autoproj/cli/jenkins.rb', line 16

def parse_vcs_credentials(credentials)
    results = Autoproj::Jenkins::Credentials.new
    credentials.each do |argument|
        credential = Autoproj::Jenkins::Credentials.parse(argument)
        results.add(credential)
    end
    results
end

#trigger_packages(*package_names) ⇒ Object

Trigger the build of the given packages

It actually only triggers the jobs that are roots in the trigger graph

Parameters:

  • the names of the packages to build



97
98
99
100
101
# File 'lib/autoproj/cli/jenkins.rb', line 97

def trigger_packages(*package_names)
    trigger_root_packages(*package_names).each do |pkg_name|
        server.trigger_job(updater.job_name_from_package_name(pkg_name))
    end
end

#trigger_root_packages(*package_names) ⇒ Array<String>

Returns the "roots" in the trigger graph

The trigger graph is the inverse of the dependency graph (a package's dependencies are built before the package itself)

Parameters:

  • the packages whose trigger roots we want to find

Returns:

  • the trigger root packages



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/autoproj/cli/jenkins.rb', line 78

def trigger_root_packages(*package_names)
    package_names.find_all do |pkg_name|
        pkg = ws.manifest.find_autobuild_package(pkg_name)
        if !pkg
            raise ArgumentError, "#{pkg_name} is not a known package"
        end
        pkg.dependencies.all? do |dep_name|
            !package_names.include?(dep_name)
        end
    end
end