Merge lp:~psivaa/uci-engine/lander-jenkins-plugin into lp:uci-engine/mthood

Proposed by Para Siva
Status: Superseded
Proposed branch: lp:~psivaa/uci-engine/lander-jenkins-plugin
Merge into: lp:uci-engine/mthood
Diff against target: 163 lines (+63/-36)
2 files modified
charms/precise/lander-jenkins/hooks/hooks.py (+61/-34)
juju-deployer/lander.yaml.tmpl (+2/-2)
To merge this branch: bzr merge lp:~psivaa/uci-engine/lander-jenkins-plugin
Reviewer Review Type Date Requested Status
Francis Ginther Needs Fixing
Review via email: mp+219018@code.launchpad.net

This proposal has been superseded by a proposal from 2014-05-16.

Commit message

Change to include parameterized-trigger plugin inside the charm instead of downloading it from the jenkins site to be made suitable for private mthood cloud

Note: For this to work well https://code.launchpad.net/~psivaa/charms/precise/jenkins/bundle-jenkins/+merge/215635 needs merging first

Description of the change

Change to include parameterized-trigger plugin inside the charm instead of downloading it from the jenkins site to be made suitable for private mthood cloud

Note: For this to work well https://code.launchpad.net/~psivaa/charms/precise/jenkins/bundle-jenkins/+merge/215635 needs merging first

To post a comment you must log in.
415. By Para Siva

Include mthood specific jenkins charm branch

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

I don't see how the plugin gets copied from the charm local directory to the jenkins plugin directory (see inline comment).

review: Needs Fixing

Unmerged revisions

415. By Para Siva

Include mthood specific jenkins charm branch

414. By Para Siva

plugin name format in yaml

413. By Para Siva

Plugins included in lander-jenkins

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'charms/precise/lander-jenkins/files'
2=== added directory 'charms/precise/lander-jenkins/files/plugins'
3=== added file 'charms/precise/lander-jenkins/files/plugins/parameterized-trigger.hpi'
4Binary files charms/precise/lander-jenkins/files/plugins/parameterized-trigger.hpi 1970-01-01 00:00:00 +0000 and charms/precise/lander-jenkins/files/plugins/parameterized-trigger.hpi 2014-05-15 11:17:32 +0000 differ
5=== modified file 'charms/precise/lander-jenkins/hooks/hooks.py'
6--- charms/precise/lander-jenkins/hooks/hooks.py 2014-03-10 22:25:00 +0000
7+++ charms/precise/lander-jenkins/hooks/hooks.py 2014-05-15 11:17:32 +0000
8@@ -14,12 +14,12 @@
9 sys.path.insert(0, os.path.join(os.environ['CHARM_DIR'], 'lib'))
10 from charmhelpers import core
11 from charmhelpers import fetch
12-from charmhelpers.fetch import bzrurl
13
14 JENKINS_HOME = '/var/lib/jenkins'
15 JENKINS_USER = 'jenkins'
16 JENKINS_GROUP = 'nogroup'
17 NUM_EXECUTORS_LINE = ' <numExecutors>{}</numExecutors>\n'
18+PLUGIN_LOCAL = os.path.join(os.environ['CHARM_DIR'], 'files/plugins')
19
20
21 def juju_info(msg, level='INFO'):
22@@ -149,49 +149,76 @@
23 plugin_list = config['plugins'].split()
24 plugins_site = config['plugins-site']
25 for plugin in plugin_list:
26- if ':' in plugin:
27- (name, version) = plugin.split(':')
28- # A specific version is being requested
29- url = '{}/download/plugins/{}/{}/{}.hpi'.format(
30- plugins_site, name, version, name)
31- plugin_file = '{}-{}.hpi'.format(name, version)
32- else:
33- url = '{}/latest/{}.hpi'.format(plugins_site, plugin)
34- plugin_file = '{}.hpi'.format(name)
35- juju_info('Installing {} from {}'.format(plugin_file, url))
36- plugin_file = os.path.join(JENKINS_HOME, 'plugins', plugin_file)
37- cmd = ['wget', '-O', plugin_file, url]
38- subprocess.check_call(cmd)
39+ plugin = '{}.hpi'.format(plugin)
40+ plugin_file = os.path.join(PLUGIN_LOCAL, plugin)
41+ if not os.path.exists(plugin_file):
42+ if ':' in plugin:
43+ (name, version) = plugin.split(':')
44+ # A specific version is being requested
45+ url = '{}/download/plugins/{}/{}/{}.hpi'.format(
46+ plugins_site, name, version, name)
47+ plugin_file = '{}-{}.hpi'.format(name, version)
48+ else:
49+ url = '{}/latest/{}.hpi'.format(plugins_site, plugin)
50+ plugin_file = plugin
51+ juju_info('Installing {} from {}'.format(plugin_file, url))
52+ plugin_file = os.path.join(JENKINS_HOME, 'plugins', plugin_file)
53+ cmd = ['wget', '-O', plugin_file, url]
54+ subprocess.check_call(cmd)
55+
56 cmd = ['chown', '-R', '{}.{}'.format(JENKINS_USER, JENKINS_GROUP),
57 plugin_file]
58 subprocess.check_call(cmd)
59
60
61-def _install_from_tarball(config):
62+def _install_from_tarball(config, upgrade):
63 juju_info('grabbing service from tarball...')
64 sdir = _service_dir(config)
65+ if not upgrade:
66+ if os.path.exists(sdir):
67+ juju_info('deleting pre-existing service directory: %s' % sdir)
68+ shutil.rmtree(sdir)
69+ os.mkdir(sdir)
70+ cmd = 'curl %s | tar -xzC %s' % (config['tarball'], sdir)
71+ subprocess.check_call(cmd, shell=True)
72+
73+
74+def _install_from_bzr(config, upgrade):
75+ juju_info('grabbing service from bzr...')
76+
77+ sdir = _service_dir(config)
78+ rev = config.get('revno', '')
79+
80+ if upgrade:
81+ args = ['bzr', 'pull']
82+ if rev:
83+ args.extend(['-r', rev])
84+ subprocess.check_call(args, cwd=sdir)
85+ return
86+
87 if os.path.exists(sdir):
88 juju_info('deleting pre-existing service directory: %s' % sdir)
89 shutil.rmtree(sdir)
90- os.mkdir(sdir)
91- cmd = 'curl %s | tar -xzC %s' % (config['tarball'], sdir)
92- subprocess.check_call(cmd, shell=True)
93-
94-
95-def _install_from_bzr(config):
96- service_dir = _service_dir(config)
97- bzr = bzrurl.BzrUrlFetchHandler()
98- if os.path.exists(service_dir):
99- juju_info('deleting pre-existing service directory: %s' % service_dir)
100- shutil.rmtree(service_dir)
101- bzr.branch(config['branch'], service_dir)
102-
103-
104-def install(config):
105+
106+ args = ['bzr', 'branch']
107+ if rev:
108+ args.extend(['-r', rev])
109+ args.append(config['branch'])
110+ args.append(sdir)
111+ subprocess.check_call(args)
112+
113+
114+def install(config, upgrade=False):
115 if config.get('vcs') == 'tarball':
116- _install_from_tarball(config)
117+ _install_from_tarball(config, upgrade)
118 else:
119- _install_from_bzr(config)
120+ _install_from_bzr(config, upgrade)
121+
122+
123+def upgrade_charm(config):
124+ install(config, True)
125+ restart_jenkins(config)
126+ restart_upstart(config)
127
128
129 def create_unit_config(config):
130@@ -210,9 +237,9 @@
131 start on (local-filesystems and net-device-up IFACE=eth0)
132 stop on runlevel [!12345]
133
134- # If the process quits unexpectadly trigger respawn it, unless it
135- # fails 15 times within 5 seconds
136+ # If the process quits unexpectedly trigger respawn it
137 respawn
138+ # unless it fails 15 times within 5 seconds
139 respawn limit 15 5
140
141 setuid {uid}
142
143=== modified file 'juju-deployer/lander.yaml.tmpl'
144--- juju-deployer/lander.yaml.tmpl 2014-03-14 10:37:28 +0000
145+++ juju-deployer/lander.yaml.tmpl 2014-05-15 11:17:32 +0000
146@@ -21,7 +21,7 @@
147 wsgi_wsgi_file: lander.wsgi:app
148 lander-jenkins:
149 charm: jenkins
150- branch: lp:~ci-engineering-private/charms/precise/jenkins/ci-train@60
151+ branch: lp:~ci-engineering-private/charms/precise/jenkins/mthood@61
152 constraints: "cpu-cores=2 mem=8 root-disk=8192M"
153 exposed: true
154 options:
155@@ -39,7 +39,7 @@
156 bot_password: lander-bot
157 sources: ${CI_PPA}
158 packages: "python-amqplib python-swiftclient lazr.enum"
159- plugins: "parameterized-trigger:2.14"
160+ plugins: "parameterized-trigger"
161 unit-config: include-base64://configs/unit_config.yaml
162 main: ./run-python ./lander/lander/run_worker.py --service-name ts-django --service-port 8080 --delay 10
163 rabbit:

Subscribers

People subscribed via source and target branches