15 Commits

Author SHA1 Message Date
Darragh Bailey
630fc6e88a No warn on old plugin conf format not in use
Use a simple object to ensure matching against any default value is
possible to distinguish been not being set by a user versus use of
a negative default value passed.

This prevents triggering an incorrect notification to the user when
the code is querying for plugin options that could override the
default behaviour and the compatibility code attempts to look up an non
existing section. It would fail to distinguish between no section
present and current value to return matching the default value
suggested.

Change-Id: I5597c2628ccb5a4282a97a4ce5d3bbe41bd9eebb
2017-12-15 14:18:11 +00:00
Jenkins
4f77324fea Merge "Wrapper pre-scm-buildstep: added support for failOnError parameter" 2017-03-29 09:55:34 +00:00
Sandro Gattuso
12c2ca3396 Wrapper pre-scm-buildstep: added support for failOnError parameter
- Added failOnError argument for pre-scm-buildstep
- Introduced buildsteps argument and moved list of build steps to match xml configuration of the preSCMbuildstep plugin.
- Updated existing test cases to match the new argument structure
- Added test case for pre-scm-buildstep to verify creation of failOnError tag
- Added verification on version to maintain retro-compatibility
- Updated documentation to fetch example from testcase definition

Change-Id: I25c19cd0552cf2de97b9c391492d95779c1360be
Task: 3163
Story: 2000690
2017-03-28 17:10:29 +00:00
Darragh Bailey
a949a274e3
Test stream no encoding bug
Tests that if no encoding is defined on the output that JJB does not
accidentally trigger a recursion issue when iterating over a large
number of jobs and attempting to wrap the output stream.

Inspired by commit message from: https://review.openstack.org/283441

Change-Id: Ie69c3af0beb9fd7c589a436e8c6d2862210f8a4c
Co-Authored-By: Hao Liu <hliu@redhat.com>
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
2016-08-29 23:43:35 -04:00
Darragh Bailey
652806a751 Ensure flush cache option obeyed
Make sure that flush cache is correct set first by config file, and
additionally that the CLI overrides any defaults.

In the V2 API work, when moving code around the flush cache option was
accidentally removed from being set by the command line or config
files. This ensures it follows the same behaviour as other similar
options.

Change-Id: I9fb1e234e5ed081ada64855389a87d2f7555469e
2016-07-22 17:55:22 +01:00
Darragh Bailey
70334fbf4b Untangle argparser and config objects
Ensure that argparser object only makes use of the JJBConfig object
instead of leaking a command line parser into a config object for API
usage.

Take care to use 'None' as default for store_true/store_false options
in order to ensure that the config file defaults are only overridden
when CLI options are explicitly set.

Change-Id: I4066ad750f9893759c2e9bdfde425fafacc7e672
2016-07-22 15:45:48 +01:00
Wayne
fc73cedb45 Introduce modular implementation of subcommands.
This commit intentionally introduces a number of important API
breakages. Specifically, the jenkins_jobs.cmd module has been pared
down to some of its most difficult-to-refactor elements.

* Create jenkins_jobs.cli.entry.JenkinsJobs class to organize command
  line parsing and execution.
* Remove references to ConfigParser object in test code, hidden as an
  implementation detail of JenkinsJobs command line parsing. This will
  be necessary in the next stage of JJB 2.0 code which will be to
  create a JJBConfig object that handles logic and presentation of
  configuration from various sources--defaults, command line
  arguments, configuration file, and maybe environment variables in
  the future.
* Remove references to Namespace object produced by argparse module.
  Required rewrite of multipath & recursive path tests with a new
  MatchesDir testtools Matcher class that validates the expected
  output for a run of JJB against a given set of yamldirs with the
  specified command line arguments.
* Use stevedore to dynamically load subcommand parsers.
* Move configuration loading/testing to its own test file. Also fix
  the global vs home directory JJB config file test.

Change-Id: If62280418ba7319c313033ab387af4284237747e
2016-07-08 09:55:44 -07:00
Darragh Bailey
b023d7e23f Wrap file objects with codecs to handle unicode
Ensure file objects including stdin/stdout objects are wrapped using
codecs to handle unicode translation to the selected encoding for
input/output.

Add tests to simulate different encodings for input/output and
consequently fix the reading of input from stdin. Include test to
trigger failure to encode a unicode valid character using 'ascii'
encoding.

Change-Id: I9a5c4c96d131873db0000377729b8b0a45aa470d
2015-10-09 10:48:01 -07:00
Darragh Bailey
f68831bd2e Only query jenkins plugins if config provided
Limit querying for plugin information from Jenkins to where an explicit
configuration file has been provided. Where no file is provided, should
avoid any requests that could result in attempting connections.

Add a config options to control this behaviour explicitly so that if a
config file is provided, it may explicitly disable querying jenkins for
additional information from plugins.

The `test` command can use this behaviour to ensure that a basic run is
possible without providing any configuration files, and can be
explicitly configured to disable querying should a config file be used
for testing.

Ensure the default sample configuration skips attempting to query so
that users may use it as a quick test for a working installation without
any network or valid jenkins url dependencies.

Change-Id: I641a3188013debf3765aaff109c4f5fa82a4cedb
2015-04-17 17:16:33 +01:00
Wayne
b4e5aa9b77 Add plugins_info to module registry object.
This makes it available for use by any module that has version-specific behavior
differences since modules always have access to the yamlparser which in turn
contains a module registry.

Change-Id: I1cae480a9a341ec2f6062904c962530dfce95057
2015-02-04 05:02:14 -08:00
Wayne
288af951b5 Reorganize tests/cmd
This commit reorganizes the 'cmd' tests by subcommand.

Previously the multipath test was using an actual fixture directory
which actually made the fixtures directory somewhat unusable by other
tests since with an upcoming change (get_plugins_version) fixtures
directories may also contain YAML that doesn't contain JJB data.

Change-Id: I4c3866e1e0769512b40e1790e40affedb13953a2
2014-12-01 18:31:58 -08:00
Khai Do
4ce214b288 add test for globbed parameters feature
add a test to verify commmand processing of the globbed parameters
feature to delete jobs.

Change-Id: Ib13a2c644388ac65cb1af5728019912d6452d852
2014-11-14 18:26:45 +00:00
Wayne
f0e53d34a1 Accept list of paths in 'path' arg.
This adds the behavior of splitting the path positional argument on colons then
processing each resulting string the same way that the path was being processed
previous to this commit.

* Adds a unit test to validate correct `path` parsing.
* Adds a unit test to validate correct `path` parsing in the recursive case.
* Documents the new behavior.

Change-Id: I0f465e02077569352cd276a8366ead5bab0eb117
2014-10-17 07:58:59 -07:00
Darragh Bailey
1eb343616f Allow test command to use conf files
It should be possible to run the `test` command with a custom config.
This allows examination of the XML outputted where config settings can
change the outputted XML. Otherwise any non-default config values will
only be used when running the `update` comand.

Add a simple test to confirm that the custom url that is unlikely to
ever be a valid default value is returned when the command is set to
`test` and a custom config is specified.

Change-Id: I193e83314a35943406bff5b182f20693edd640ba
2014-07-09 15:57:00 +00:00
Khai Do
1df929c58a tests for JJB command processing
Add a few tests for JJB command processing.  This is just to get
started I'm hoping more will come.

Change-Id: Iff964af025f6a3d7ba4acd91b1e0242285a11bc3
2014-07-09 08:55:10 -07:00