From 5e2b386423ccecf65e41fecf920179f34d387589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Radom=C3=ADr=20Bos=C3=A1k?= Date: Tue, 23 May 2017 23:50:29 +0200 Subject: [PATCH] Add command which returns job config in xml Fixes #30 --- contrib/bash-completion/jenkins | 3 ++- jenkins_cli/cli.py | 5 +++++ jenkins_cli/cli_arguments.py | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/contrib/bash-completion/jenkins b/contrib/bash-completion/jenkins index f8e6c9f..f6784c3 100755 --- a/contrib/bash-completion/jenkins +++ b/contrib/bash-completion/jenkins @@ -11,6 +11,7 @@ _jenkins() builds \ start \ info \ + configxml \ setbranch \ stop \ console \ @@ -28,7 +29,7 @@ _jenkins() COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 ;; - queue|building|builds|start|info|setbranch|stop|console|changes) + queue|building|builds|start|info|configxml|setbranch|stop|console|changes) opts="-h --help" COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 diff --git a/jenkins_cli/cli.py b/jenkins_cli/cli.py index 54258c3..1995578 100644 --- a/jenkins_cli/cli.py +++ b/jenkins_cli/cli.py @@ -192,6 +192,11 @@ def info(self, args): scm_name, branch_name)) + def configxml(self, args): + job_name = self._check_job(args.job_name) + job_config = self.jenkins.get_job_config(job_name) + print(job_config) + def setbranch(self, args): job_name = self._check_job(args.job_name) xml = self.jenkins.get_job_config(job_name) diff --git a/jenkins_cli/cli_arguments.py b/jenkins_cli/cli_arguments.py index 66ce2df..43ab3aa 100644 --- a/jenkins_cli/cli_arguments.py +++ b/jenkins_cli/cli_arguments.py @@ -43,6 +43,9 @@ def load_parser(): start_parser = subparsers.add_parser('info', help='Job info') start_parser.add_argument('job_name', help='Job to get info for') + start_parser = subparsers.add_parser('configxml', help='Job config in xml format') + start_parser.add_argument('job_name', help='Job to get config for') + set_branch = subparsers.add_parser('setbranch', help='Set VCS branch (Mercurial or Git)') set_branch.add_argument('job_name', help='Job to set branch for') set_branch.add_argument('branch_name', help='Name of the VCS branch')