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(a)redhat.com>
---
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..ec81448 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, projects, 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 ce49f5a..b4e9343 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