Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Docopt #17

Merged
merged 25 commits into from

3 participants

@txels
Owner

Addresses #11

josephmc5 and others added some commits
josephmc5 need to see if project exists before creating 0163f9c
@josephmc5 josephmc5 check before delete if project exists 0e13dc5
@chaosblog chaosblog add job existence check
create_copy:
- template must exist
- new job must not already exist
42a2545
@chaosblog chaosblog add optional proxy parameter
optional proxy parameter for explicit proxy settings divergent to the system
settings
7e278d3
@chaosblog chaosblog added proxy parameter d62f469
@chaosblog chaosblog Change console script entry points
ajk console scripts replaced by autojenkins
one executable for all commands
1cd0a48
@chaosblog chaosblog insert docopt header
first changes for switch from optparse to docopt
insert docopt usage and options part
ec3ecc0
@chaosblog chaosblog List-Command via docopt
remove options first.
8104d83
@chaosblog chaosblog Remove old staticmethod list() 48ac7a9
@chaosblog chaosblog Add some http-error handling 0f53847
@chaosblog chaosblog Delete-command via docopt
add some error handling
134ef16
@chaosblog chaosblog Remove old staticmethod delete() 40cfe16
@chaosblog chaosblog Add job not buildable exception
check if a job exist before it should be build
ef54fbf
@chaosblog chaosblog Build-command via docopt
add some error handling
275ee40
@chaosblog chaosblog Remove old staticmethod build() 3072e6e
@chaosblog chaosblog Add some error handling
line length fix
1651ca9
@chaosblog chaosblog Create-command via docopt
add some error handling
93dee96
@chaosblog chaosblog Fix PEP8 301dbee
@chaosblog chaosblog Remove old staticmethod create() 6376598
@chaosblog chaosblog Fix PEP8 c7f9a86
@chaosblog chaosblog Returncode for create job
Exit with 1 on error
9613cdc
@chaosblog chaosblog Add proxies parameter
PEP8 fix
7a1868d
@chaosblog chaosblog test fix 1647bac
@chaosblog chaosblog Add docopt as to requirements 2b677bf
@chaosblog chaosblog Remove create_opts_parser
remove unused optparse
47d0afa
@txels txels merged commit 17d690d into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 6, 2012
  1. need to see if project exists before creating

    josephmc5 authored
  2. @josephmc5
Commits on Feb 6, 2013
  1. @chaosblog

    add job existence check

    chaosblog authored
    create_copy:
    - template must exist
    - new job must not already exist
  2. @chaosblog

    add optional proxy parameter

    chaosblog authored
    optional proxy parameter for explicit proxy settings divergent to the system
    settings
Commits on Feb 7, 2013
  1. @chaosblog

    added proxy parameter

    chaosblog authored
  2. @chaosblog

    Change console script entry points

    chaosblog authored
    ajk console scripts replaced by autojenkins
    one executable for all commands
  3. @chaosblog

    insert docopt header

    chaosblog authored
    first changes for switch from optparse to docopt
    insert docopt usage and options part
  4. @chaosblog

    List-Command via docopt

    chaosblog authored
    remove options first.
  5. @chaosblog
Commits on Feb 8, 2013
  1. @chaosblog
  2. @chaosblog

    Delete-command via docopt

    chaosblog authored
    add some error handling
Commits on Feb 11, 2013
  1. @chaosblog
  2. @chaosblog

    Add job not buildable exception

    chaosblog authored
    check if a job exist before it should be build
  3. @chaosblog

    Build-command via docopt

    chaosblog authored
    add some error handling
Commits on Feb 12, 2013
  1. @chaosblog
  2. @chaosblog

    Add some error handling

    chaosblog authored
    line length fix
  3. @chaosblog

    Create-command via docopt

    chaosblog authored
    add some error handling
  4. @chaosblog

    Fix PEP8

    chaosblog authored
  5. @chaosblog
  6. @chaosblog

    Fix PEP8

    chaosblog authored
  7. @chaosblog

    Returncode for create job

    chaosblog authored
    Exit with 1 on error
  8. @chaosblog

    Add proxies parameter

    chaosblog authored
    PEP8 fix
Commits on Feb 22, 2013
  1. @chaosblog

    test fix

    chaosblog authored
Commits on Mar 4, 2013
  1. @chaosblog
  2. @chaosblog

    Remove create_opts_parser

    chaosblog authored
    remove unused optparse
This page is out of date. Refresh to see the latest.
View
80 autojenkins/jobs.py
@@ -4,6 +4,33 @@
from jinja2 import Template
+class AutojenkinsError(Exception):
+ pass
+
+
+class JobInexistent(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __str__(self):
+ return repr(self.msg)
+
+
+class JobExists(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __str__(self):
+ return repr(self.msg)
+
+
+class JobNotBuildable(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+ def __str__(self):
+ return repr(self.msg)
+
API = 'api/python'
NEWJOB = '{0}/createItem'
JOB_URL = '{0}/job/{1}'
@@ -25,12 +52,22 @@ class HttpStatusError(Exception):
pass
+class HttpUnauthorized(Exception):
+ pass
+
+
+class HttpForbidden(Exception):
+ pass
+
+
class HttpNotFoundError(HttpStatusError):
pass
HTTP_ERROR_MAP = {
- 404: HttpNotFoundError,
+ 401: HttpUnauthorized, # credentials wrong
+ 403: HttpForbidden, # insufficient rights
+ 404: HttpNotFoundError
}
@@ -50,10 +87,11 @@ def _validate(response):
class Jenkins(object):
"""Main class to interact with a Jenkins server."""
- def __init__(self, base_url, auth=None, verify_ssl_cert=True):
+ def __init__(self, base_url, auth=None, verify_ssl_cert=True, proxies={}):
self.ROOT = base_url
self.auth = auth
self.verify_ssl_cert = verify_ssl_cert
+ self.proxies = proxies
def _url(self, command, *args):
"""
@@ -76,6 +114,7 @@ def _http_get(self, url, **kwargs):
response = requests.get(url,
auth=self.auth,
verify=self.verify_ssl_cert,
+ proxies=self.proxies,
**kwargs)
return _validate(response)
@@ -88,6 +127,7 @@ def _http_post(self, url, **kwargs):
response = requests.post(url,
auth=self.auth,
verify=self.verify_ssl_cert,
+ proxies=self.proxies,
**kwargs)
return _validate(response)
@@ -114,6 +154,12 @@ def all_jobs(self):
jobs = eval(response.content).get('jobs', [])
return [(job['name'], job['color']) for job in jobs]
+ def job_exists(self, jobname):
+ jobs = self.all_jobs()
+ for (name, color) in jobs:
+ if name == jobname:
+ return True
+
def job_url(self, jobname):
"""
Get the human-browseable URL for a job.
@@ -194,15 +240,26 @@ def create(self, jobname, config_file, **context):
template = Template(content)
content = template.render(**context)
- return self._build_post(NEWJOB,
- data=content,
- params=params,
- headers={'Content-Type': 'application/xml'})
+ if self.job_exists(jobname):
+ raise Exception("Job already exists")
+ else:
+ return self._build_post(NEWJOB,
+ data=content,
+ params=params,
+ headers={'Content-Type': 'application/xml'}
+ )
def create_copy(self, jobname, template_job, enable=True, **context):
"""
Create a job from a template job.
"""
+ if not self.job_exists(template_job):
+ raise JobInexistent("Template job '%s' doesn't exists" % jobname)
+
+ if self.job_exists(jobname):
+ raise JobExists("Another job with the name '%s'already exists"
+ % jobname)
+
config = self.get_config_xml(template_job)
# remove stupid quotes added by Jenkins
@@ -210,6 +267,7 @@ def create_copy(self, jobname, template_job, enable=True, **context):
config = config.replace('}}&quot;<', '}}<')
template_config = Template(config)
+
config = template_config.render(**context)
if enable:
config = config.replace('<disabled>true</disabled>',
@@ -244,6 +302,11 @@ def build(self, jobname, wait=False, grace=10):
:param wait:
If ``True``, wait until job completes building before returning
"""
+ if not self.job_exists(jobname):
+ raise JobInexistent("Job '%s' doesn't exists" % jobname)
+ if not self.job_info(jobname)['buildable']:
+ raise JobNotBuildable("Job '%s' is not buildable (deactivated)."
+ % jobname)
response = self._build_post(BUILD, jobname)
if not wait:
return response
@@ -256,7 +319,10 @@ def delete(self, jobname):
"""
Delete a job.
"""
- return self._build_post(DELETE, jobname)
+ if self.job_exists(jobname):
+ return self._build_post(DELETE, jobname)
+ else:
+ raise JobInexistent("Job '%s' doesn't exist" % jobname)
def enable(self, jobname):
"""
View
209 autojenkins/run.py
@@ -1,7 +1,36 @@
-import optparse
+"""Autojenkins CLI
+
+Usage:
+ autojenkins list <host> [(--user=<USER> --password=<PASSWORD>)]
+ [--proxy=<PROXY>][-nr]
+ autojenkins create <host> <jobname> <template> [-D=<VAR=VALUE>]... [--build]
+ [(--user=<USER> --password=<PASSWORD>)] [--proxy=<PROXY>]
+ autojenkins build <host> <jobname> [--wait]
+ [(--user=<USER> --password=<PASSWORD>)][--proxy=<PROXY>]
+ autojenkins delete <host> <jobname>...
+ [(--user=<USER> --password=<PASSWORD>)][--proxy=<PROXY>]
+ autojenkins --version
+ autojenkins -h | --help
+
+Options:
+ -h, --help show this help message and exit
+ --version Show version
+ -u USER, --user=USER username
+ -p PASSWORD, --password=PASSWORD
+ password or API token
+ -D VAR=VALUE substitution variables to be used in the template
+ -x, --proxy=PROXY Proxyserver (Host:Port)
+ -b, --build start build after creation
+ -w, --wait wait until the build completes
+ -n, --no-color do not use colored output
+ -r, --raw print raw list of jobs
+
+"""
+
import sys
+from docopt import docopt
-from autojenkins import Jenkins
+from autojenkins import Jenkins, jobs
COLOR_MEANING = {
'blue': ('1;32', 'SUCCESS'),
@@ -14,57 +43,57 @@
}
-def create_opts_parser(command, params="[jobname] [options]"):
- """
- Create parser for command-line options
- """
- usage = "Usage: %prog host " + params
- desc = 'Run autojenkins to {0}.'.format(command)
- parser = optparse.OptionParser(description=desc, usage=usage)
- parser.add_option('-u', '--user',
- help='username')
- parser.add_option('-p', '--password',
- help='password or token')
- return parser
-
-
def get_variables(options):
"""
Read all variables and values from ``-Dvariable=value`` options
"""
split_eq = lambda x: x.split('=')
- data = dict(map(split_eq, options.D))
+ data = dict(map(split_eq, options))
return data
-def get_auth(options):
+def get_proxy(args):
"""
- Return a tuple of (user, password) or None if no authentication
+ Return a proxy dictionary
"""
- if hasattr(options, 'user'):
- return (options.user, getattr(options, 'password', None))
+ if args is None or args['--proxy'] is None:
+ return {"http": "", "https": ""}
else:
+ return {"http": args['--proxy'], "https": args['--proxy']}
+
+
+def get_auth(args):
+ """
+ Return a tuple of (user, password) or None if no authentication
+ """
+ if args is None or args['--user'] is None:
return None
+ else:
+ return (args['--user'], args['--password'])
def create_job(host, jobname, options):
"""
Create a new job
"""
- data = get_variables(options)
+ data = get_variables(options['-D'])
print ("""
Creating job '{0}' from template '{1}' with:
{2}
- """.format(jobname, options.template, data))
-
- jenkins = Jenkins(host, auth=get_auth(options))
- response = jenkins.create_copy(jobname, options.template, **data)
- if response.status_code == 200 and options.build:
- print('Triggering build.')
- jenkins.build(jobname)
- print ('Job URL: {0}'.format(jenkins.job_url(jobname)))
- return response.status_code
+ """.format(jobname, options['<template>'], data))
+
+ jenkins = Jenkins(host, proxies=get_proxy(options), auth=get_auth(options))
+ try:
+ response = jenkins.create_copy(jobname, options['<template>'], **data)
+ if response.status_code == 200 and options['--build']:
+ print('Triggering build.')
+ jenkins.build(jobname)
+ print ('Job URL: {0}'.format(jenkins.job_url(jobname)))
+ return response.status_code < 400
+ except jobs.JobExists as error:
+ print "Error: %s" % error.msg
+ return False
def build_job(host, jobname, options):
@@ -81,26 +110,36 @@ def build_job(host, jobname, options):
* If not wait: ``True`` if HTTP status code is not an error code
"""
print ("Start building job '{0}'".format(jobname))
-
- jenkins = Jenkins(host, auth=get_auth(options))
- response = jenkins.build(jobname, wait=options.wait)
- if options.wait:
- result = response['result']
- print('Result = "{0}"'.format(result))
- return result == 'SUCCESS'
- else:
- return response.status_code < 400
+ jenkins = Jenkins(host, proxies=get_proxy(options), auth=get_auth(options))
+ try:
+ response = jenkins.build(jobname, wait=options['--wait'])
+ if options['--wait']:
+ result = response['result']
+ print('Result = "{0}"'.format(result))
+ return result == 'SUCCESS'
+ else:
+ print "Build '%s' started" % jobname
+ return response.status_code < 400
+ except (jobs.JobInexistent, jobs.JobNotBuildable) as error:
+ print "Error: %s" % error.msg
+ return False
def delete_jobs(host, jobnames, options):
"""
Delete existing jobs.
"""
- jenkins = Jenkins(host, auth=get_auth(options))
+ jenkins = Jenkins(host, proxies=get_proxy(options), auth=get_auth(options))
for jobname in jobnames:
print ("Deleting job '{0}'".format(jobname))
- response = jenkins.delete(jobname)
- print(response.status_code)
+ try:
+ response = jenkins.delete(jobname)
+ if response.status_code == 200:
+ print "Job '%s' deleted" % jobname
+ except jobs.JobInexistent as error:
+ print "Error: %s" % error.msg
+ except (jobs.HttpForbidden, jobs.HttpUnauthorized):
+ pass
def list_jobs(host, options, color=True, raw=False):
@@ -118,9 +157,9 @@ def list_jobs(host, options, color=True, raw=False):
position = 1
if not raw:
print ("All jobs in {0}".format(host))
- jenkins = Jenkins(host, auth=get_auth(options))
- jobs = jenkins.all_jobs()
- for name, color in jobs:
+ jenkins = Jenkins(host, proxies=get_proxy(options), auth=get_auth(options))
+ joblist = jenkins.all_jobs()
+ for name, color in joblist:
if '_' in color:
color = color.split('_')[0]
building = True
@@ -133,70 +172,18 @@ def list_jobs(host, options, color=True, raw=False):
class Commands:
@staticmethod
- def create():
- parser = create_opts_parser('create a job')
- parser.add_option('-D', metavar='VAR=VALUE',
- action="append",
- help='substitution variables to be used in the '
- 'template')
- parser.add_option('-t', '--template', default='template',
- help='the template job to copy from')
- parser.add_option('-b', '--build',
- action="store_true", dest="build", default=False,
- help='start a build right after creation')
-
- (options, args) = parser.parse_args()
-
- if len(args) == 2:
- host, jobname = args
- create_job(host, jobname, options)
- else:
- parser.print_help()
-
- @staticmethod
- def build():
- parser = create_opts_parser('build a job')
- parser.add_option('-w', '--wait',
- action="store_true", dest="wait", default=False,
- help='wait until the build completes')
-
- (options, args) = parser.parse_args()
-
- if len(args) == 2:
- host, jobname = args
- success = build_job(host, jobname, options)
+ def main():
+ args = docopt(__doc__, version='autojenkins 0.9.0-docopt')
+ if args['list']:
+ list_jobs(args['<host>'], args, not args['--no-color'],
+ args['--raw'])
+ elif args['delete']:
+ delete_jobs(args['<host>'], args['<jobname>'], args)
+ elif args['build']:
+ success = build_job(args['<host>'], args['<jobname>'][0], args)
+ if not success:
+ sys.exit(1)
+ elif args['create']:
+ success = create_job(args['<host>'], args['<jobname>'][0], args)
if not success:
sys.exit(1)
- else:
- parser.print_help()
-
- @staticmethod
- def delete():
- parser = create_opts_parser('delete one or more jobs',
- params="[jobname]+ [options]")
-
- (options, args) = parser.parse_args()
-
- if len(args) >= 2:
- host, jobnames = args[0], args[1:]
- delete_jobs(host, jobnames, options)
- else:
- parser.print_help()
-
- @staticmethod
- def list():
- parser = create_opts_parser('list all jobs', params='')
- parser.add_option('-n', '--no-color',
- action="store_true", dest="color", default=False,
- help='do not use colored output')
- parser.add_option('-r', '--raw',
- action="store_true", dest="raw", default=False,
- help='print raw list of jobs')
-
- (options, args) = parser.parse_args()
-
- if len(args) == 1:
- host, = args
- list_jobs(host, options, not options.color, options.raw)
- else:
- parser.print_help()
View
17 autojenkins/tests/test_run.py
@@ -8,7 +8,8 @@
def test_delete_jobs(jenkins):
jenkins.return_value = Mock()
delete_jobs('http://jenkins', ['hello', 'bye'], None)
- jenkins.assert_called_with('http://jenkins', auth=None)
+ jenkins.assert_called_with('http://jenkins',
+ proxies={'http': '', 'https': ''}, auth=None)
assert_equals(2, jenkins.return_value.delete.call_count)
assert_equals(
[(('hello',), {}), (('bye',), {})],
@@ -16,13 +17,17 @@ def test_delete_jobs(jenkins):
@patch('autojenkins.run.Jenkins')
-def test_delete_jobs_authenticated(jenkins):
+@patch('autojenkins.jobs.Jenkins.job_exists')
+def test_delete_jobs_authenticated(job_exists, jenkins):
+ job_exists.return_value = True
jenkins.return_value = Mock()
- options = Mock()
- options.user = 'carles'
- options.password = 'secret'
+ options = {}
+ options['--user'] = 'carles'
+ options['--password'] = 'secret'
+ options['--proxy'] = ''
delete_jobs('http://jenkins', ['hello'], options)
- jenkins.assert_called_with('http://jenkins', auth=('carles', 'secret'))
+ jenkins.assert_called_with('http://jenkins', auth=('carles', 'secret'),
+ proxies={'http': '', 'https': ''})
assert_equals(1, jenkins.return_value.delete.call_count)
assert_equals(
[(('hello',), {})],
View
52 autojenkins/tests/test_unit_jobs.py
@@ -28,6 +28,15 @@ def mock_response(fixture=None, status=200):
return response
+def side_effect_job_exists(*args, **kwargs):
+ if args[0] == 'job':
+ return False
+ elif args[0] == 'template':
+ return True
+ elif args[0] == 'name':
+ return True
+
+
@ddt
@patch('autojenkins.jobs.requests')
class TestJenkins(TestCase):
@@ -42,6 +51,7 @@ def test_all_jobs(self, requests):
jobs = self.jenkins.all_jobs()
requests.get.assert_called_once_with('http://jenkins/api/python',
verify=True,
+ proxies={},
auth=None)
self.assertEqual(jobs, [('job1', 'blue')])
@@ -59,7 +69,7 @@ def test_last_result(self, requests, *args):
self.assertEqual(23, response['result'])
self.assertEqual(
(('https://builds.apache.org/job/Solr-Trunk/1783/api/python',),
- {'auth': None, 'verify': True}),
+ {'auth': None, 'verify': True, 'proxies': {}}),
requests.get.call_args_list[1]
)
@@ -77,6 +87,7 @@ def test_get_methods_with_jobname(self, case, requests):
requests.get.assert_called_once_with(
'http://jenkins/' + url.format('name'),
verify=True,
+ proxies={},
auth=None)
getattr(self, 'checks_{0}'.format(method))(response)
@@ -87,6 +98,7 @@ def test_build_info(self, requests):
requests.get.assert_called_once_with(
'http://jenkins/' + url,
verify=True,
+ proxies={},
auth=None)
def check_result(self, response, route, value):
@@ -105,7 +117,7 @@ def checks_job_info(self, response):
(('lastSuccessfulBuild', 'number'), 1778),
(('lastSuccessfulBuild', 'url'),
'https://builds.apache.org/job/Solr-Trunk/1778/'),
- ])
+ ])
def checks_last_build_info(self, response):
self.check_results(
@@ -114,7 +126,7 @@ def checks_last_build_info(self, response):
(('number',), 1783),
(('result',), 'FAILURE'),
(('changeSet', 'kind'), 'svn'),
- ])
+ ])
def checks_last_build_report(self, response):
self.check_results(
@@ -122,7 +134,7 @@ def checks_last_build_report(self, response):
[(('duration',), 692.3089),
(('failCount',), 1),
(('suites', 0, 'name'), 'org.apache.solr.BasicFunctionalityTest'),
- ])
+ ])
def checks_last_success(self, response):
self.check_results(
@@ -131,15 +143,16 @@ def checks_last_success(self, response):
(('building',), False),
(('artifacts', 0, 'displayPath'),
'apache-solr-4.0-2012-02-29_09-07-30-src.tgz'),
- ])
+ ])
def checks_get_config_xml(self, response):
self.assertTrue(response.startswith('<?xml'))
self.assertTrue(response.endswith('</project>'))
# TODO: test job creation, and set_config_xml
-
- def test_create(self, requests):
+ @patch('autojenkins.jobs.Jenkins.job_exists')
+ def test_create(self, job_exists, requests):
+ job_exists.side_effect = side_effect_job_exists
requests.post.return_value = mock_response()
config_xml = path.join(fixture_path, 'create_copy.txt')
self.jenkins.create('job', config_xml, value='2')
@@ -150,9 +163,12 @@ def test_create(self, requests):
headers={'Content-Type': 'application/xml'},
params={'name': 'job'},
data=CFG,
+ proxies={},
verify=True)
- def test_create_copy(self, requests):
+ @patch('autojenkins.jobs.Jenkins.job_exists')
+ def test_create_copy(self, job_exists, requests):
+ job_exists.side_effect = side_effect_job_exists
requests.get.return_value = mock_response('create_copy.txt')
requests.post.return_value = mock_response()
self.jenkins.create_copy('job', 'template', value='2')
@@ -163,6 +179,7 @@ def test_create_copy(self, requests):
headers={'Content-Type': 'application/xml'},
params={'name': 'job'},
data=CFG,
+ proxies={},
verify=True)
def test_transfer(self, requests):
@@ -176,6 +193,7 @@ def test_transfer(self, requests):
headers={'Content-Type': 'application/xml'},
params={'name': 'job'},
data=CFG,
+ proxies={},
verify=True)
@data(
@@ -184,15 +202,21 @@ def test_transfer(self, requests):
('enable', 'job/{0}/enable'),
('disable', 'job/{0}/disable'),
)
- def test_post_methods_with_jobname_no_data(self, case, requests):
+ @patch('autojenkins.jobs.Jenkins.job_info')
+ @patch('autojenkins.jobs.Jenkins.job_exists')
+ def test_post_methods_with_jobname_no_data(self, case, job_exists,
+ job_info, requests):
method, url = case
# Jenkins API post methods return status 302 upon success
requests.post.return_value = mock_response(status=302)
+ job_exists.side_effect = side_effect_job_exists
+ job_info.return_value = {'buildable': True}
response = getattr(self.jenkins, method)('name')
self.assertEqual(302, response.status_code)
requests.post.assert_called_once_with(
'http://jenkins/' + url.format('name'),
auth=None,
+ proxies={},
verify=True)
def test_set_config_xml(self, requests):
@@ -206,14 +230,19 @@ def test_set_config_xml(self, requests):
headers={'Content-Type': 'application/xml'},
data=CFG,
auth=None,
+ proxies={},
verify=True)
@patch('autojenkins.jobs.time')
@patch('autojenkins.jobs.Jenkins.last_result')
@patch('autojenkins.jobs.Jenkins.wait_for_build')
- def test_build_with_wait(self, wait_for_build, last_result, time,
- requests):
+ @patch('autojenkins.jobs.Jenkins.job_exists')
+ @patch('autojenkins.jobs.Jenkins.job_info')
+ def test_build_with_wait(self, job_info, job_exists, wait_for_build,
+ last_result, time, requests):
"""Test building a job synchronously"""
+ job_exists.side_effect = side_effect_job_exists
+ job_info.return_value = {'buildable': True}
requests.post.return_value = mock_response(status=302)
last_result.return_value = {'result': 'HELLO'}
result = self.jenkins.build('name', wait=True)
@@ -221,6 +250,7 @@ def test_build_with_wait(self, wait_for_build, last_result, time,
requests.post.assert_called_once_with(
'http://jenkins/job/name/build',
auth=None,
+ proxies={},
verify=True)
last_result.assert_called_once_with('name')
time.sleep.assert_called_once_with(10)
View
1  requirements.txt
@@ -1,2 +1,3 @@
requests
jinja2
+docopt
View
5 setup.py
@@ -18,10 +18,7 @@
install_requires=['requests', 'jinja2'],
entry_points = dict(
console_scripts = [
- 'ajk-create = autojenkins.run:Commands.create',
- 'ajk-build = autojenkins.run:Commands.build',
- 'ajk-delete = autojenkins.run:Commands.delete',
- 'ajk-list = autojenkins.run:Commands.list',
+ 'autojenkins = autojenkins.run:Commands.main'
],
),
#include_package_data=True,
Something went wrong with that request. Please try again.