Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent handling of whitespaces in the project name #22

Open
sysarch-repo opened this issue Aug 8, 2024 · 1 comment
Open

Inconsistent handling of whitespaces in the project name #22

sysarch-repo opened this issue Aug 8, 2024 · 1 comment

Comments

@sysarch-repo
Copy link

sysarch-repo commented Aug 8, 2024

When running a test using Docker run, the project name in testcases.yaml can include whitespaces, e.g.
project_name: Hello world tests
The xTesting suite correctly interprets the whitespaces during the test and in the test report.

However, if the same testcases.yaml is used in xTestingCI where the ansiblle role collivier.xtesting is executed using the following site.yaml:

---
- hosts:
    - 127.0.0.1
  roles:
    - role: collivier.xtesting
      project: Hello world tests <<<<<< the problematic parameter value
      registry_deploy: true
      repo: 127.0.0.1
      dport: 5000
      suites:
        - container: hello-world-tests
          tests:
            - Test1

.. then the ansible task fails with:

TASK [collivier.xtesting : Creating jenkins_jobs.ini] *********************************************************************************
changed: [127.0.0.1]

TASK [collivier.xtesting : Creating run.yaml for Hello world tests] *******************************************************************
changed: [127.0.0.1]

TASK [collivier.xtesting : Loading Jenkins jobs] **************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"changed": false, "cmd": ["jenkins-jobs", "--conf", "/tmp/jenkins_jobs.ini", "update", "/tmp/Hello", "world", "tests.yaml"], "delta": "0:00:00.773301", "end": "2024-08-08 12:58:53.819591", "msg": "non-zero return code", "rc": 1, "start": "2024-08-08 12:58:53.046290", "stderr": "INFO:jenkins_jobs.cli.subcommand.update:Updating jobs in ['/tmp/Hello'] (['world', 'tests.yaml'])\nTraceback (most recent call last):\n  File \"/usr/bin/jenkins-jobs\", line 10, in <module>\n    sys.exit(main())\n  File \"/usr/lib/python3/dist-packages/jenkins_jobs/cli/entry.py\", line 174, in main\n    jjb.execute()\n  File \"/usr/lib/python3/dist-packages/jenkins_jobs/cli/entry.py\", line 154, in execute\n    ext.obj.execute(self.options, self.jjb_config)\n  File \"/usr/lib/python3/dist-packages/jenkins_jobs/cli/subcommand/update.py\", line 134, in execute\n    builder, xml_jobs, xml_views = self._generate_xmljobs(options, jjb_config)\n  File \"/usr/lib/python3/dist-packages/jenkins_jobs/cli/subcommand/update.py\", line 114, in _generate_xmljobs\n    parser.load_files(options.path)\n  File \"/usr/lib/python3/dist-packages/jenkins_jobs/parser.py\", line 136, in load_files\n    self.parse(in_file)\n  File \"/usr/lib/python3/dist-packages/jenkins_jobs/parser.py\", line 176, in parse\n    with io.open(fn, \"r\", encoding=\"utf-8\") as fp:\nFileNotFoundError: [Errno 2] No such file or directory: '/tmp/Hello'", "stderr_lines": ["INFO:jenkins_jobs.cli.subcommand.update:Updating jobs in ['/tmp/Hello'] (['world', 'tests.yaml'])", "Traceback (most recent call last):", "  File \"/usr/bin/jenkins-jobs\", line 10, in <module>", "    sys.exit(main())", "  File \"/usr/lib/python3/dist-packages/jenkins_jobs/cli/entry.py\", line 174, in main", "    jjb.execute()", "  File \"/usr/lib/python3/dist-packages/jenkins_jobs/cli/entry.py\", line 154, in execute", "    ext.obj.execute(self.options, self.jjb_config)", "  File \"/usr/lib/python3/dist-packages/jenkins_jobs/cli/subcommand/update.py\", line 134, in execute", "    builder, xml_jobs, xml_views = self._generate_xmljobs(options, jjb_config)", "  File \"/usr/lib/python3/dist-packages/jenkins_jobs/cli/subcommand/update.py\", line 114, in _generate_xmljobs", "    parser.load_files(options.path)", "  File \"/usr/lib/python3/dist-packages/jenkins_jobs/parser.py\", line 136, in load_files", "    self.parse(in_file)", "  File \"/usr/lib/python3/dist-packages/jenkins_jobs/parser.py\", line 176, in parse", "    with io.open(fn, \"r\", encoding=\"utf-8\") as fp:", "FileNotFoundError: [Errno 2] No such file or directory: '/tmp/Hello'"], "stdout": "", "stdout_lines": []}

The workaround is not using whitespaces in the project name value included in testcases.yaml and site.yml (both values have to be IMO aligned, i.e. be the same). It just would be nicer to use / see whitespaces in the log report. I did not try using quotes or apos.

@collivier
Copy link
Owner

thank you @sysarch-repo

Yes whitespaces are known as an issue here (and I would recommend not to use whitespaces here).
Checking if I could make it work quickly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants