Skip to content

Commit

Permalink
Fix bug with bundle install path
Browse files Browse the repository at this point in the history
  • Loading branch information
alejdg committed Jan 22, 2020
1 parent 2127988 commit d59beb7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ options:
default: ""
description: >
Site to download deb packages from when installing jenkins from bundle.
If this configuration not set, the jenkins deb package needs to be manually
If this configuration is not set, the jenkins deb package needs to be manually
copied over to the charm files/ dir before deployment and named jenkins.deb.
username:
type: string
Expand Down
25 changes: 16 additions & 9 deletions lib/charms/layer/jenkins/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(self, apt=apt, ch_host=None):
if core_url == "":
self._jc = JenkinsCore()
else:
self._jc = JenkinsCore(hookenv.config()["bundle-site"])
self._jc = JenkinsCore(jenkins_core_url=hookenv.config()["bundle-site"])

def distro_codename(self):
"""Return the distro release code name, e.g. 'precise' or 'trusty'."""
Expand Down Expand Up @@ -72,12 +72,17 @@ def jenkins_version(self):

def _install_from_bundle(self):
"""Install Jenkins from bundled package."""
# Check bundled package exists.
charm_dir = hookenv.charm_dir()
bundle_path = os.path.join(charm_dir, "files", "jenkins.deb")
if not os.path.isfile(bundle_path):
message = "'%s' doesn't exist. No package bundled." % (bundle_path)
raise Exception(message)
config = hookenv.config()
if config["bundle-site"] == "":
# Check bundled package exists.
charm_dir = hookenv.charm_dir()
bundle_path = os.path.join(charm_dir, "files", "jenkins.deb")
if not os.path.isfile(bundle_path):
message = "'%s' doesn't exist. No package bundled." % (bundle_path)
raise Exception(message)
else:
bundle_path = os.path.join(hookenv.charm_dir(), "jenkins.deb")
self._bundle_download(bundle_path)
hookenv.log(
"Installing from bundled Jenkins package: %s:" % bundle_path)
self._install_local_deb(bundle_path)
Expand Down Expand Up @@ -118,8 +123,10 @@ def _setup_source(self, release):
key = k.read()
self._apt.add_source(source, key=key)

def _bundle_download(self):
return
def _bundle_download(self, path=None):
hookenv.log(
"Downloading bundle from %s" % self._jc.jenkins_repo)
self._jc.get_binary_package(path)

def jenkins_upgradable(self):
"""
Expand Down

0 comments on commit d59beb7

Please sign in to comment.