Skip to content
This repository was archived by the owner on Sep 23, 2024. It is now read-only.

Commit 671e73d

Browse files
committed
Create Jenkins project interface outside watcher
Create a complete Jenkins project interface instance and pass it to the watcher, instead of having the watcher create it. This prepares the watcher to using abstract scheduler interface, instead of Jenkins specifically.
1 parent acff492 commit 671e73d

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

sktm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import logging
2020
import os
2121
import sktm
22+
import sktm.jenkins
2223

2324

2425
def setup_parser():
@@ -120,9 +121,10 @@ def load_config(args):
120121
setup_logging(args.verbose)
121122
cfg = load_config(args)
122123
logging.debug("cfg=%s", cfg)
124+
jenkins_project = sktm.jenkins.Project(cfg.get("jjname"), cfg.get("jurl"),
125+
cfg.get("jlogin"), cfg.get("jpass"))
123126

124-
sw = sktm.watcher(cfg.get("jurl"), cfg.get("jlogin"), cfg.get("jpass"),
125-
cfg.get("jjname"), cfg.get("db"), cfg.get("makeopts"))
127+
sw = sktm.watcher(jenkins_project, cfg.get("db"), cfg.get("makeopts"))
126128

127129
args.func(sw, cfg)
128130
try:

sktm/__init__.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ class jtype(enum.IntEnum):
3131

3232
# TODO This is no longer just a watcher. Rename/refactor/describe accordingly.
3333
class watcher(object):
34-
def __init__(self, jenkinsurl, jenkinslogin, jenkinspassword,
35-
jenkinsjobname, dbpath, makeopts=None):
34+
def __init__(self, jenkins_project, dbpath, makeopts=None):
3635
"""
3736
Initialize a "watcher".
3837
3938
Args:
40-
jenkinsurl: Jenkins instance URL.
41-
jenkinslogin: Jenkins user name.
42-
jenkinspassword: Jenkins user password.
43-
jenkinsjobname: Name of the Jenkins job to trigger and watch.
39+
jenkins_project: Interface to the Jenkins project to trigger
40+
and watch (sktm.jenkins.Project).
4441
dbpath: Path to the job status database file.
4542
makeopts: Extra arguments to pass to "make" when
4643
building.
@@ -49,9 +46,7 @@ def __init__(self, jenkinsurl, jenkinslogin, jenkinspassword,
4946
# Database instance
5047
self.db = sktm.db.skt_db(os.path.expanduser(dbpath))
5148
# Jenkins project interface instance
52-
self.jk = sktm.jenkins.Project(jenkinsjobname,
53-
jenkinsurl, jenkinslogin,
54-
jenkinspassword)
49+
self.jk = jenkins_project
5550
# Extra arguments to pass to "make"
5651
self.makeopts = makeopts
5752
# List of pending Jenkins builds, each one represented by a 3-tuple

0 commit comments

Comments
 (0)