Merge ~dannf/charms/+source/scalebot-jenkins:env-fix into ~ce-hyperscale/charms/+source/scalebot-jenkins:master

Proposed by dann frazier
Status: Merged
Merged at revision: 6c5ff13183e38a59cacd4ac291250f9a5d17be86
Proposed branch: ~dannf/charms/+source/scalebot-jenkins:env-fix
Merge into: ~ce-hyperscale/charms/+source/scalebot-jenkins:master
Diff against target: 63 lines (+14/-11)
1 file modified
reactive/scalebot-jenkins.py (+14/-11)
Reviewer Review Type Date Requested Status
Sean Feole Approve
Review via email: mp+316594@code.launchpad.net
To post a comment you must log in.
Revision history for this message
dann frazier (dannf) wrote :

I verified this by deploying and adding a jenkins job that just runs "/usr/bin/env". The output included:

PYTHONPATH=/srv/scalebot/repo/lib/LibJuju
SCALEBOT_REPO=/srv/scalebot/repo

Also, this reminded me that git clone isn't pulling submodules (i.e. libjuju), so we need to fix that as well.

Revision history for this message
Sean Feole (sfeole) wrote :

+1 merge it

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/reactive/scalebot-jenkins.py b/reactive/scalebot-jenkins.py
2index 6c698a2..a774aec 100644
3--- a/reactive/scalebot-jenkins.py
4+++ b/reactive/scalebot-jenkins.py
5@@ -18,8 +18,10 @@ from charms.reactive import (
6 )
7 from charms.reactive.helpers import data_changed
8
9-SCALEBOT_ROOT = "/srv/scalebot"
10-PYTHONPATH = "$SCALEBOT_ROOT/lib/LibJuju"
11+SCALEBOT_HOME = "/srv/scalebot"
12+SCALEBOT_REPO = os.path.join(SCALEBOT_HOME, "repo")
13+PYTHONPATH = os.path.join(SCALEBOT_REPO, "lib", "LibJuju")
14+
15
16 @when("extension.available")
17 def configure_jenkins_jobbuilder(extension):
18@@ -52,14 +54,15 @@ def unconfigure_jobbuilder():
19
20 @only_once
21 def configure_scalebot_env():
22- ''' Set SCALEBOT_ROOT and PYTHONPATH'''
23+ ''' Set SCALEBOT_REPO and PYTHONPATH'''
24 sbprofile = "/etc/profile.d/scalebot.sh"
25- sbroot = 'export SCALEBOT_ROOT="%s"' % SCALEBOT_ROOT
26+ sbrepo = 'export SCALEBOT_REPO="%s"' % SCALEBOT_REPO
27 ppath = 'export PYTHONPATH="%s"' % PYTHONPATH
28
29- configfile = open(sbprofile, "w")
30- configfile.write("#Export Scalebot required paths\n%s\n%s\n" % (sbroot, ppath))
31- configfile.close()
32+ with open(sbprofile, 'w') as f:
33+ f.write("#Export Scalebot required paths\n")
34+ f.write("%s\n" % (sbrepo))
35+ f.write("%s\n" % (ppath))
36
37
38 def scalebot_git_config_check():
39@@ -96,12 +99,12 @@ def scalebot_git_clone():
40 status_set('maintenance', 'Cloning Scalebot repository')
41
42 try:
43- shutil.rmtree(SCALEBOT_ROOT)
44+ shutil.rmtree(SCALEBOT_HOME)
45 except FileNotFoundError:
46 pass
47
48- os.makedirs(SCALEBOT_ROOT)
49- shutil.chown(SCALEBOT_ROOT, user='ubuntu', group='ubuntu')
50+ os.makedirs(SCALEBOT_HOME)
51+ shutil.chown(SCALEBOT_HOME, user='ubuntu', group='ubuntu')
52
53 keyfile = tempfile.NamedTemporaryFile(mode='w', delete=False)
54 keypath = keyfile.name
55@@ -115,7 +118,7 @@ def scalebot_git_clone():
56 git_ssh = '"/usr/bin/ssh -v -i %s -o UserKnownHostsFile=%s"' % \
57 (keypath, known_hosts)
58 git_cmd = 'GIT_SSH_COMMAND=%s /usr/bin/git clone -b %s %s %s' % \
59- (git_ssh, branch, repo, os.path.join(SCALEBOT_ROOT, 'repo'))
60+ (git_ssh, branch, repo, os.path.join(SCALEBOT_HOME, 'repo'))
61 su_git_cmd = ['/bin/su', '-', 'ubuntu', '-c', git_cmd]
62 log("Beginning git clone")
63 log(su_git_cmd)

Subscribers

People subscribed via source and target branches

to all changes: