Skip to content

Commit 578d23b

Browse files
committed
username and password now optional
1 parent c0b6b80 commit 578d23b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

jenkins_cli/cli.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ def auth(cls, host=None, username=None, password=None, timeout=socket._GLOBAL_DE
3333
settings_dict = cls.read_settings_from_file()
3434
try:
3535
host = host or settings_dict['host']
36-
username = username or settings_dict['username'] or None
37-
password = password or settings_dict['password'] or None
36+
username = username or settings_dict.get('username', None)
37+
password = password or settings_dict.get('password', None)
3838
except KeyError:
39-
raise CliException('host, username and password has to be specified by the command-line options or .jenkins-cli file')
39+
raise CliException('jenkins "host" has to be specified by the command-line options or in .jenkins-cli file')
4040
return jenkins.Jenkins(host, username, password, timeout)
4141

4242
@classmethod
@@ -48,7 +48,7 @@ def read_settings_from_file(cls):
4848
home_folder = os.path.expanduser("~")
4949
filename = os.path.join(home_folder, cls.SETTINGS_FILE_NAME)
5050
if not os.path.exists(filename):
51-
raise CliException('.jenkins-cli file not found.')
51+
return {}
5252
f = open(filename, 'r')
5353
jenkins_settings = f.read()
5454
except Exception as e:

0 commit comments

Comments
 (0)