only change view name from all to All when All was requested

Otherwise you get errors like:

    Traceback (most recent call last):
      File "path/bin/jenkins-jobs", line 8, in <module>
        sys.exit(main())
                 ^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins_jobs/cli/entry.py", line 179, in main
        jjb.execute()
      File "path/lib64/python3.12/site-packages/jenkins_jobs/cli/entry.py", line 158, in execute
        ext.obj.execute(self.options, self.jjb_config)
      File "path/lib64/python3.12/site-packages/jenkins_jobs/cli/subcommand/update.py", line 154, in execute
        n = builder.delete_old_managed_views(keep=keep_views)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins_jobs/builder.py", line 402, in delete_old_managed_views
        if view["name"] not in keep and self.is_view(view["name"], use_cache=False):
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins_jobs/builder.py", line 384, in is_view
        return self.jenkins.view_exists(view_name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins/__init__.py", line 1857, in view_exists
        if self.get_view_name(name) == name:
           ^^^^^^^^^^^^^^^^^^^^^^^^
      File "path/lib64/python3.12/site-packages/jenkins/__init__.py", line 1834, in get_view_name
        raise JenkinsException(
    jenkins.JenkinsException: Jenkins returned an unexpected view name All (expected: all)

Fixes: a8f0d8cfda
Change-Id: I82b5abd8429190e871e432732d502b0640ebc99b
Signed-off-by: Evgeni Golov <evgeni@golov.de>
This commit is contained in:
Evgeni Golov 2024-05-10 13:17:16 +02:00
parent 6b757a7c36
commit b147d86446

View File

@ -1827,7 +1827,7 @@ class Jenkins(object):
return None
else:
actual = json.loads(response)['name']
if actual == 'all':
if actual == 'all' and short_name == 'All':
actual = 'All'
if actual != short_name:
raise JenkinsException(