Debian Codegraph @

jenkins_jobs/cli/subcommand/test.py

raw
1 #!/usr/bin/env python
2 # Copyright (C) 2015 Wayne Warren
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 import logging
17 import sys
18
19 import jenkins_jobs.cli.subcommand.update as update
20
21
22 logger = logging.getLogger(__name__)
23
24
25 class TestSubCommand(update.UpdateSubCommand):
26 def parse_args(self, subparser):
27 test = subparser.add_parser("test")
28
29 self.parse_option_recursive_exclude(test)
30
31 self.parse_arg_path(test)
32 self.parse_arg_names(test)
33
34 test.add_argument(
35 "--config-xml",
36 action="store_true",
37 dest="config_xml",
38 default=False,
39 help="use alternative output file layout using config.xml files",
40 )
41 test.add_argument(
42 "-p",
43 "--plugin-info",
44 dest="plugins_info_path",
45 default=None,
46 help="path to plugin info YAML file",
47 )
48 test.add_argument(
49 "-o", dest="output_dir", default=sys.stdout, help="path to output XML"
50 )
51
52 def execute(self, options, jjb_config):
53 if not options.config_xml:
54 logger.warning(
55 "(Deprecated) The default output behavior of"
56 " `jenkins-jobs test` when given the --output"
57 " flag will change in JJB 3.0."
58 " Instead of writing jobs to OUTPUT/jobname;"
59 " they will be written to OUTPUT/jobname/config.xml."
60 " The new behavior can be enabled by the passing"
61 " `--config-xml` parameter."
62 )
63
64 builder, xml_jobs, xml_views = self.make_jobs_and_views_xml(
65 jjb_config, options.path, options.names
66 )
67
68 builder.update_jobs(
69 xml_jobs,
70 output=options.output_dir,
71 n_workers=1,
72 config_xml=options.config_xml,
73 )
74 builder.update_views(
75 xml_views,
76 output=options.output_dir,
77 n_workers=1,
78 config_xml=options.config_xml,
79 )