[libvirt] [jenkins-ci PATCH 1/8] lcitool: Add "-r REVISION" argument for build

Andrea Bolognani abologna at redhat.com
Fri Aug 31 10:16:14 UTC 2018


On Wed, 2018-08-29 at 17:08 +0200, Andrea Bolognani wrote:
> This will allow users to build arbitrary branches from
> arbitrary git repositories, but for the moment all it
> does is parse the argument and pass it down to the
> Ansible playbook.
> 
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
>  guests/lcitool | 36 ++++++++++++++++++++++++++----------
>  1 file changed, 26 insertions(+), 10 deletions(-)

As helpfully pointed out by Erik, this change has the unintended
consequence of making '-r REVISION' mandatory every time a playbook
is invoked, including when using '-a update'.

The patch below fixes the issue; consider it squashed in.

diff --git a/guests/lcitool b/guests/lcitool
index c12143d..0729d55 100755
--- a/guests/lcitool
+++ b/guests/lcitool
@@ -367,13 +367,15 @@ class Application:
         ansible_hosts = ",".join(self._inventory.expand_pattern(hosts))
         selected_projects = self._projects.expand_pattern(projects)

-        if revision is None:
-            raise Error("Missing git revision")
-        tokens = revision.split('/')
-        if len(tokens) < 2:
-            raise Error("Invalid git revision '{}'".format(revision))
-        git_remote = tokens[0]
-        git_branch = '/'.join(tokens[1:])
+        if revision is not None:
+            tokens = revision.split('/')
+            if len(tokens) < 2:
+                raise Error("Invalid git revision '{}'".format(revision))
+            git_remote = tokens[0]
+            git_branch = '/'.join(tokens[1:])
+        else:
+            git_remote = None
+            git_branch = None

         ansible_cfg_path = os.path.join(base, "ansible.cfg")
         playbook_base = os.path.join(base, "playbooks", playbook)
@@ -494,6 +496,9 @@ class Application:
         self._execute_playbook("update", hosts, projects, revision)

     def _action_build(self, hosts, projects, revision):
+        if revision is None:
+            raise Error("Missing git revision")
+
         self._execute_playbook("build", hosts, projects, revision)

     def _action_dockerfile(self, hosts, projects, _revision):
-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list