Skip to content

Commit 3a4a949

Browse files
committed
builds command
1 parent 3bb4fff commit 3a4a949

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ Server URL, Username and password may be specified either by the command line ar
3535
setbranch Set SCM branch
3636
stop Stop job
3737
console Show console for last build
38+
builds Show builds for job
3839
```

jenkins_cli/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ def main():
2222
formatter_class=argparse.RawTextHelpFormatter,
2323
description="Status description:\n\n" + "\n".join(get_jobs_legend()))
2424
jobs_parser.add_argument('-a', help='Show only active jobs', default=False, action='store_true')
25+
jobs_parser.add_argument('-b', help='Show only jobs thats in build progress', default=False, action='store_true')
2526

2627
subparsers.add_parser('queue', help='Shows builds queue')
2728

2829
subparsers.add_parser('building', help='Build executor status')
2930

31+
builds_parser = subparsers.add_parser('builds', help='Show builds for job')
32+
builds_parser.add_argument('job_name', help='Job name of the builds')
33+
3034
start_parser = subparsers.add_parser('start', help='Start job')
3135
start_parser.add_argument('job_name', help='Job to start', nargs='*')
3236

jenkins_cli/cli.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def _get_jobs(self, args):
115115
jobs = self.jenkins.get_jobs()
116116
if args.a:
117117
jobs = [j for j in jobs if j.get('color') != 'disabled']
118-
# jobs = sorted(jobs, key=lambda j: j.get('name'))
118+
if hasattr(args, 'b') and args.b:
119+
jobs = [j for j in jobs if 'anime' in j.get('color')]
119120
return jobs
120121

121122
def queue(self, args):
@@ -188,6 +189,13 @@ def start(self, args):
188189
start_status = self.jenkins.build_job(job_name)
189190
print("%s: %s" % (job_name, 'started' if not start_status else start_status))
190191

192+
def builds(self, args):
193+
job_name = self._check_job(args.job_name)
194+
job_info = self.jenkins.get_job_info(job_name, 1)
195+
print(job_info)
196+
# start_status = self.jenkins.build_job(job_name)
197+
# print("%s: %s" % (job_name, 'started' if not start_status else start_status))
198+
191199
def stop(self, args):
192200
job_name = self._check_job(args.job_name)
193201
info = self.jenkins.get_job_info(job_name)

0 commit comments

Comments
 (0)