Skip to content

Commit

Permalink
Merge pull request #212 from ismet55555/fix-abort-permission-error
Browse files Browse the repository at this point in the history
  • Loading branch information
ismet55555 committed Mar 6, 2023
2 parents aa8c483 + 58ad459 commit 28ea48d
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.0.83
current_version = 0.0.84
commit = True
tag = True
allow_dirty = False
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.83
0.0.84
2 changes: 1 addition & 1 deletion docs/source/cli_outline.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Below is a complete outline of the `yojenkins` CLI command structure.

!!! note
As of Version: **0.0.83**
As of Version: **0.0.84**

```text
yojenkins
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import setuptools

# Package version number (Updated via bump2version tool)
__version__ = "0.0.83"
__version__ = "0.0.84"

def check_py_version():
"""Check the python version"""
Expand Down
2 changes: 1 addition & 1 deletion yojenkins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

__title__ = 'yojenkins'
__summary__ = "A CLI tool to interface with Jenkins server"
__version__ = "0.0.83"
__version__ = "0.0.84"
__author__ = "Ismet Handzic"
__copyright__ = "Copyright 2022 %s" % __author__
5 changes: 1 addition & 4 deletions yojenkins/monitor/build_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,11 +393,8 @@ def __monitor_draw(self, scr, build_url: str, sound: bool = False) -> bool:
if build_url:
self.server_interaction = True
build_number = self.build.abort(build_url=build_url)
if build_number == 0:
# TODO: Show error message
pass
else:
# TODO: Show error message
# TODO: Show UI error message for missing build_url
pass
self.build_abort = 0
else:
Expand Down
8 changes: 6 additions & 2 deletions yojenkins/yo_jenkins/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from yojenkins.monitor import BuildMonitor
from yojenkins.utility import utility
from yojenkins.utility.utility import diff_show, fail_out, print2
from yojenkins.utility.utility import diff_show, fail_out, failures_out, print2
from yojenkins.yo_jenkins.auth import Auth
from yojenkins.yo_jenkins.jenkins_item_classes import JenkinsItemClasses
from yojenkins.yo_jenkins.rest import Rest
Expand Down Expand Up @@ -253,7 +253,11 @@ def abort(self,
logger.debug(f'Aborting build: {url} ...')
request_url = f"{url.strip('/')}/stop"
if not self.rest.request(request_url, 'post', is_endpoint=False)[2]:
fail_out('Failed to abort build. Build may not exist or is queued')
messages = [
'Failed to abort build', ' - Build may not exist, is queued, or you are not authorized to abort',
' - For more details run with --debug'
]
failures_out(messages)

logger.debug('Successfully aborted build')

Expand Down
6 changes: 4 additions & 2 deletions yojenkins/yo_jenkins/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,13 @@ def request(self,

# Check for permission denied
if response.status_code in [401, 403, 405]:
logger.debug('PERMISSION DENIED - Request denied due to insufficient privileges')
logger.debug('PERMISSION DENIED - HTTP(S) request denied due to insufficient privileges')
return {}, {}, False

# Check conflict
if response.status_code in [409]:
logger.debug('CONFLICT - Request failed due to conflict. Possible duplicate entry')
logger.debug('CONFLICT - HTTP(s) request failed due to conflict. Possible duplicate entry')
return {}, {}, False

# If a head request, only return headers
if request_type.lower() == 'head':
Expand Down

0 comments on commit 28ea48d

Please sign in to comment.