[jenkins-ci PATCH 11/12] lcitool: Support building arbitrary branches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Building master is useful for CI purposes and to debug CI
failures locally, but when developing we want to be able
to build a personal branch to validate in-progress changes.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
 guests/lcitool                           | 30 ++++++++++++++++--------
 guests/playbooks/build/jobs/defaults.yml |  1 -
 2 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/guests/lcitool b/guests/lcitool
index 2901a92..9d4b628 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -351,8 +351,13 @@ class Application:
             metavar="PROJECTS",
             help="list of projects to consider",
         )
+        self._parser.add_argument(
+            "-b",
+            metavar="BRANCH",
+            help="git branch to use when performing builds",
+        )
 
-    def _execute_playbook(self, playbook, hosts, projects):
+    def _execute_playbook(self, playbook, hosts, projects, branch):
         base = Util.get_base()
 
         flavor = self._config.get_flavor()
@@ -372,6 +377,7 @@ class Application:
             "root_password_file": root_pass_file,
             "flavor": flavor,
             "selected_projects": selected_projects,
+            "branch": branch,
         })
 
         cmd = [
@@ -396,15 +402,15 @@ class Application:
         except Exception:
             raise Error("Failed to run {} on '{}'".format(playbook, hosts))
 
-    def _action_hosts(self, _hosts, _projects):
+    def _action_hosts(self, _hosts, _projects, _branch):
         for host in self._inventory.expand_pattern("all"):
             print(host)
 
-    def _action_projects(self, _hosts, _projects):
+    def _action_projects(self, _hosts, _projects, _branch):
         for project in self._projects.expand_pattern("all"):
             print(project)
 
-    def _action_install(self, hosts, _projects):
+    def _action_install(self, hosts, _projects, _branch):
         base = Util.get_base()
 
         flavor = self._config.get_flavor()
@@ -475,13 +481,16 @@ class Application:
             except Exception:
                 raise Error("Failed to install '{}'".format(host))
 
-    def _action_update(self, hosts, projects):
-        self._execute_playbook("update", hosts, projects)
+    def _action_update(self, hosts, projects, _branch):
+        self._execute_playbook("update", hosts, project, None)
+
+    def _action_build(self, hosts, projects, branch):
+        if branch is None:
+            raise Error("Missing branch")
 
-    def _action_build(self, hosts, projects):
-        self._execute_playbook("build", hosts, projects)
+        self._execute_playbook("build", hosts, projects, branch)
 
-    def _action_dockerfile(self, hosts, projects):
+    def _action_dockerfile(self, hosts, projects, _branch):
         mappings = self._projects.get_mappings()
 
         hosts = self._inventory.expand_pattern(hosts)
@@ -553,11 +562,12 @@ class Application:
         action = cmdline.a
         hosts = cmdline.h
         projects = cmdline.p
+        branch = cmdline.b
 
         method = "_action_{}".format(action.replace("-", "_"))
 
         if hasattr(self, method):
-            getattr(self, method).__call__(hosts, projects)
+            getattr(self, method).__call__(hosts, projects, branch)
         else:
             raise Error("Invalid action '{}'".format(action))
 
diff --git a/guests/playbooks/build/jobs/defaults.yml b/guests/playbooks/build/jobs/defaults.yml
index 2e4a078..f0474ca 100644
--- a/guests/playbooks/build/jobs/defaults.yml
+++ b/guests/playbooks/build/jobs/defaults.yml
@@ -1,5 +1,4 @@
 ---
-branch: master
 variant: ''
 all_machines:
   - libvirt-centos-7
-- 
2.17.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux