Merge lp:~psivaa/charms/trusty/jenkaas/install-plugins into lp:~canonical-ci-engineering/charms/trusty/jenkaas/trunk

Proposed by Para Siva
Status: Merged
Approved by: Para Siva
Approved revision: 13
Merged at revision: 4
Proposed branch: lp:~psivaa/charms/trusty/jenkaas/install-plugins
Merge into: lp:~canonical-ci-engineering/charms/trusty/jenkaas/trunk
Prerequisite: lp:~psivaa/charms/trusty/jenkaas/install-jenkins
Diff against target: 59 lines (+19/-9)
2 files modified
hooks/actions.py (+18/-8)
hooks/services.py (+1/-1)
To merge this branch: bzr merge lp:~psivaa/charms/trusty/jenkaas/install-plugins
Reviewer Review Type Date Requested Status
Joe Talbott (community) Approve
Francis Ginther Approve
Review via email: mp+261841@code.launchpad.net

Commit message

Installing jenkins plugins copied to charm/files/plugins by the spec

Description of the change

Installing jenkins plugins copied to charm/files/plugins by the spec

To post a comment you must log in.
Revision history for this message
Francis Ginther (fginther) wrote :

I agree that we'll need to install the plugins by passing them along inside the charm payload. But I think we're better off actually coping them to /var/lib/jenkins/plugins and making sure they are owned by "jenkins:jenkins".

review: Needs Fixing
7. By Para Siva

Merging install jenkins

8. By Para Siva

pyflakes and pep8

9. By Para Siva

Copying instead of symlinking

10. By Para Siva

pep8 and pyflakes

11. By Para Siva

Set the ownership to the right plugins

Revision history for this message
Para Siva (psivaa) wrote :

Thanks Francis for the review and the informal review :). I think I've addressed your concerns. Would appreciate a re-review.

12. By Para Siva

Remove config file setup

13. By Para Siva

pyflakes

Revision history for this message
Francis Ginther (fginther) wrote :

Looks good.

review: Approve
Revision history for this message
Joe Talbott (joetalbott) wrote :

This looks good to me. One minor comment inline regarding os.path.exists()/mkdir() combination.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'files/plugins'
2=== modified file 'hooks/actions.py'
3--- hooks/actions.py 2015-06-16 08:34:49 +0000
4+++ hooks/actions.py 2015-06-16 15:39:50 +0000
5@@ -1,9 +1,13 @@
6-import base64
7+import glob
8+import grp
9 import os
10+import pwd
11+import shutil
12 import subprocess
13
14 from charmhelpers import fetch
15 from charmhelpers.core import hookenv
16+from charmhelpers.core.host import mkdir
17 from charmhelpers.payload import execd
18
19 SERVICE_NAME = 'jenkaas'
20@@ -31,13 +35,19 @@
21 subprocess.check_call(['dpkg', '-i', jenkins_deb])
22
23
24-def update_config_file(service_name):
25- hookenv.log(
26- 'Updating service configuration file: %s', SERVICE_CONFIGNAME)
27- config_content = base64.b64decode(config['config-file'])
28- config_path = os.path.join(_service_dir(), SERVICE_CONFIGNAME)
29- with open(config_path, 'w') as f:
30- f.write(config_content)
31+def install_plugins(service_name):
32+ hookenv.log('Installing plugins')
33+ charm_plugins_dir = os.path.join(hookenv.charm_dir(), 'files/plugins')
34+ plugins = glob.glob(os.path.join(charm_plugins_dir, '*.hpi'))
35+ service_plugin_dir = os.path.join(_service_dir(), 'plugins')
36+ if not os.path.exists(service_plugin_dir):
37+ mkdir(service_plugin_dir, 'jenkins', 'jenkins', 0o755)
38+ uid = pwd.getpwnam("jenkins").pw_uid
39+ gid = grp.getgrnam("jenkins").gr_gid
40+ for plugin in plugins:
41+ shutil.copy2(plugin, service_plugin_dir)
42+ os.chown(os.path.join(service_plugin_dir, os.path.basename(plugin)),
43+ uid, gid)
44
45
46 def install_jenkins_dep_pkges(service_name):
47
48=== modified file 'hooks/services.py'
49--- hooks/services.py 2015-06-16 08:11:39 +0000
50+++ hooks/services.py 2015-06-16 15:39:50 +0000
51@@ -15,7 +15,7 @@
52 actions.basenode,
53 actions.install_jenkins_dep_pkges,
54 actions.install_jenkins,
55- actions.update_config_file,
56+ actions.install_plugins,
57 helpers.render_template(
58 source='upstart.conf',
59 target='/etc/init/jenkaas.conf'),

Subscribers

People subscribed via source and target branches