Class: Autoproj::CLI::Jenkins
- Inherits:
-
InspectionTool
- Object
- InspectionTool
- Autoproj::CLI::Jenkins
- Defined in:
- lib/autoproj/cli/jenkins.rb
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#updater ⇒ Object
readonly
Returns the value of attribute updater.
Instance Method Summary collapse
- #add_or_update_packages(*package_names, dev: false, vcs_credentials: []) ⇒ Object
- #create_or_update_buildconf_job(*package_names, dev: false, credentials_id: nil, vcs_credentials: []) ⇒ Object
-
#initialize(ws, job_prefix: '', **options) ⇒ Jenkins
constructor
A new instance of Jenkins.
- #parse_vcs_credentials(credentials) ⇒ Object
-
#trigger_packages(*package_names) ⇒ Object
Trigger the build of the given packages.
-
#trigger_root_packages(*package_names) ⇒ Array<String>
Returns the "roots" in the trigger graph.
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: '', **) super(ws) @server = Autoproj::Jenkins::Server.new(**) @updater = Autoproj::Jenkins::Updater.new(ws, server, job_prefix: job_prefix) end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
7 8 9 |
# File 'lib/autoproj/cli/jenkins.rb', line 7 def server @server end |
#updater ⇒ Object (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, dev: false, vcs_credentials: []) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/autoproj/cli/jenkins.rb', line 46 def add_or_update_packages(*package_names, dev: false, vcs_credentials: []) initialize_and_load source_packages, _ = finalize_setup(package_names, non_imported_packages: :ignore) 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, gemfile: gemfile, autoproj_install_path: autoproj_install_path, vcs_credentials: parse_vcs_credentials(vcs_credentials)) end |
#create_or_update_buildconf_job(*package_names, 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 |
# File 'lib/autoproj/cli/jenkins.rb', line 25 def create_or_update_buildconf_job(*package_names, 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, 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
95 96 97 98 99 |
# File 'lib/autoproj/cli/jenkins.rb', line 95 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)
76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/autoproj/cli/jenkins.rb', line 76 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 |