Skip to content

Commit 0206ee6

Browse files
committed
resolves #15
1 parent b9ddef9 commit 0206ee6

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jenkins [-h] [--host jenkins-url] [--username username]
1313
{jobs,queue,building,start,info,set_branch,stop,console} ...
1414
```
1515

16-
Server URL, Username and password may be specified either by the command line arguments or in configuration file **(.jenkins-cli)**. Command line arguments has the highest priority, after that the **.jenkins-cli** file from current folder is taking into account. If there is no.jenkins-cli file in current folder, settings will be read from **.jenkins-cli** from the program folder
16+
Server URL, Username and password may be specified either by the command line arguments or in configuration file **(.jenkins-cli)**. Command line arguments has the highest priority, after that the **.jenkins-cli** file from current folder is taking into account. If there is no.jenkins-cli file in current folder, settings will be read from **.jenkins-cli** from the home folder
1717

1818
# Optional arguments:
1919
```bash

jenkins_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def main():
1010
description='Server URL, Username and password may be specified either by the command line arguments '
1111
'or in configuration file (.jenkins-cli). Command line arguments has the highest priority, '
1212
'after that the .jenkins-cli file from current folder is taking into account. If there is no'
13-
'.jenkins-cli file in current folder, setiings will be read from .jenkins-cli from the program'
13+
'.jenkins-cli file in current folder, setiings will be read from .jenkins-cli from the home'
1414
'folder')
1515
parser.add_argument('--host', metavar='jenkins-url', help='Jenkins Server Url', default=None)
1616
parser.add_argument('--username', metavar='username', help='Jenkins Username', default=None)

jenkins_cli/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ def read_settings_from_file(cls):
4545
current_folder = os.getcwd()
4646
filename = "%s/%s" % (current_folder, cls.SETTINGS_FILE_NAME)
4747
if not os.path.exists(filename):
48-
program_folder = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
49-
filename = "%s/%s" % (program_folder, cls.SETTINGS_FILE_NAME)
48+
home_folder = os.path.expanduser("~")
49+
filename = "%s/%s" % (home_folder, cls.SETTINGS_FILE_NAME)
50+
if not os.path.exists(filename):
51+
raise CliException('.jenkins-cli file not found.')
5052
f = open(filename, 'r')
5153
jenkins_settings = f.read()
5254
except Exception as e:

0 commit comments

Comments
 (0)