Calling basicConfig on import prevents the user from calling it with his
own parameter, because basicConfig acts as a no-op after first call.
Example:
```python
import logging
from jenkins_jobs.cli.entry import JenkinsJobs
def main():
logging.basicConfig(format="[%(levelname)s] %(message)s", level=logging.DEBUG)
logging.debug("debug log entry")
logging.critical("critical log entry")
if __name__ == "__main__":
main()
```
Result before patch does not match desired level nor format:
```text
CRITICAL:root:critical log entry
```
This patch moves the call of basicConfig in root package __main__, so
that basicConfig is only called on explicitly "non imported" code-path
This allows the user to call basicConfig with its preferred parameters
when importing from cli.entry, all the while still calling it
automatically when run as a package (through __main__)
Result after patch:
```text
[DEBUG] debug log entry
[CRITICAL] critical log entry
```
Tests
- added tests/cmd/test_logging.py
- added test fails before patch
- added test passes after patch
- no regression seen
- other test continue to pass from 3.8 to 3.13
- IMPORTANT: not tested with 3.7 (uv does not provide it)
- other tests fail with 3.14 and 3.15
Change-Id: If0fa2adff682265dd315835e3fce40cb3fc288df
README
Jenkins Job Builder takes simple descriptions of Jenkins jobs in YAML or JSON format and uses them to configure Jenkins. You can keep your job descriptions in human readable text format in a version control system to make changes and auditing easier. It also has a flexible template system, so creating many similarly configured jobs is easy.
To install:
$ pip install --user jenkins-job-builder
Online documentation:
Developers
Bug report:
Repository:
Cloning:
git clone https://opendev.org/jjb/jenkins-job-builder.git
Install pre-commit from https://pre-commit.com/#intro in order to run some minimal testing on your commits.
A virtual environment is recommended for development. For example, Jenkins Job Builder may be installed from the top level directory:
$ virtualenv .venv
$ source .venv/bin/activate
$ pip install -r test-requirements.txt -e .
Patches are submitted via Gerrit at:
Please do not submit GitHub pull requests, they will be automatically closed.
Mailing list:
IRC:
#openstack-jjbon OFTC
More details on how you can contribute is available on our wiki at:
Writing a patch
We ask that all code submissions be pep8 and pyflakes clean. The easiest
way to do that is to run tox
before submitting code for review in Gerrit. It will run
pep8 and pyflakes in the same manner as the
automated test suite that will run on proposed patchsets.
When creating new YAML components, please observe the following style conventions:
- All YAML identifiers (including component names and arguments) should be lower-case and multiple word identifiers should use hyphens. E.g., "build-trigger".
- The Python functions that implement components should have the same name as the YAML keyword, but should use underscores instead of hyphens. E.g., "build_trigger".
This consistency will help users avoid simple mistakes when writing YAML, as well as developers when matching YAML components to Python implementation.
Unit Tests
Unit tests have been included and are in the tests
folder. Many unit tests samples are included as examples in our
documentation to ensure that examples are kept current with existing
behaviour. To run the unit tests, execute the command:
tox -e py38
Unit tests could be run in parallel, using pytest-parallel pytest plugin:
tox -e py38 -- --workers=auto
- Note: View
tox.inito run tests on other versions of Python, generating the documentation and additionally for any special notes on running the test to validate documentation external URLs from behind proxies.
Installing without setup.py
For YAML support, you will need libyaml installed.
Mac OS X:
$ brew install libyaml
Then install the required python packages using pip:
$ sudo pip install PyYAML python-jenkins