Merge lp:~matsubara/charms/trusty/jenkins-slave/trusty-jenkins-slave into lp:~juju-qa/charms/trusty/jenkins-slave/trunk

Proposed by Diogo Matsubara
Status: Merged
Merged at revision: 21
Proposed branch: lp:~matsubara/charms/trusty/jenkins-slave/trusty-jenkins-slave
Merge into: lp:~juju-qa/charms/trusty/jenkins-slave/trunk
Diff against target: 70 lines (+18/-8)
5 files modified
hooks/slave-relation-changed (+13/-1)
hooks/slave-relation-joined (+1/-1)
hooks/start (+0/-3)
hooks/stop (+0/-3)
metadata.yaml (+4/-0)
To merge this branch: bzr merge lp:~matsubara/charms/trusty/jenkins-slave/trusty-jenkins-slave
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+270418@code.launchpad.net

Description of the change

Fix bug 1232886 by exporting the credentials from the jenkins master to the jenkins slave, so the slave agent can download the slave.jnlp file from the master and connect successfully.

Adds the extension interface to the charm so it can be used with the ci-configurator charm

Remove start/stop hooks since the slave should only be started or stopped based on its relation to the master.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Hi Diogo.

I think this change will break slaves that don't need credentials.

review: Needs Information (code)
26. By Diogo Matsubara

review comments: fix credentials to cope with old slave versions that doesn't need credentials

Revision history for this message
Diogo Matsubara (matsubara) wrote :

> Hi Diogo.
>
> I think this change will break slaves that don't need credentials.

Hi Curtis,

I fixed the code per your review comments. Now the code checks if for username and password and update the config file accordingly. If there's no username and password, it will only update the jenkins url.

Thanks for the review!

Diogo

Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you.

review: Approve (code)
27. By Diogo Matsubara

forgot a space in if conditional

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'hooks/slave-relation-changed'
2--- hooks/slave-relation-changed 2012-07-27 10:51:16 +0000
3+++ hooks/slave-relation-changed 2015-09-23 15:10:40 +0000
4@@ -1,6 +1,6 @@
5 #!/bin/bash
6
7-set -e
8+set -eux
9
10 # Setup connection to master instance once set
11 url=$(relation-get url)
12@@ -19,6 +19,18 @@
13 -e "s!^#*JENKINS_URL.*!JENKINS_URL=${url}!" \
14 /etc/default/jenkins-slave
15
16+# Update JENKINS_ARGS so it can connect to the master and retrieve the agent
17+# jnlp.
18+username=$(relation-get username)
19+password=$(relation-get password)
20+credentials=""
21+if [[ -n "${password}" && -n "${username}" ]]; then
22+ juju-log "Configuring jenkins-slave credentials..."
23+ credentials="-jnlpCredentials ${username}:${password}"
24+fi
25+
26+sed -i -e "s!^JENKINS_ARGS.*!JENKINS_ARGS=\"-jnlpUrl \$JENKINS_URL/computer/\$JENKINS_HOSTNAME/slave-agent.jnlp ${credentials}\"!" /etc/default/jenkins-slave
27+
28 juju-log "Restarting jenkins-slave..."
29 # Startup the jenkins-slave service
30 stop jenkins-slave 2>/dev/null || true
31
32=== modified file 'hooks/slave-relation-joined'
33--- hooks/slave-relation-joined 2014-04-09 15:33:59 +0000
34+++ hooks/slave-relation-joined 2015-09-23 15:10:40 +0000
35@@ -1,6 +1,6 @@
36 #!/bin/bash
37
38-set -e
39+set -eux
40
41 # Set the slave hostname to match the juju unit
42 # in the jenkins master instance
43
44=== removed file 'hooks/start'
45--- hooks/start 2011-08-02 08:53:54 +0000
46+++ hooks/start 1970-01-01 00:00:00 +0000
47@@ -1,3 +0,0 @@
48-#!/bin/bash
49-
50-start jenkins-slave || true
51
52=== removed file 'hooks/stop'
53--- hooks/stop 2011-08-02 08:53:54 +0000
54+++ hooks/stop 1970-01-01 00:00:00 +0000
55@@ -1,3 +0,0 @@
56-#!/bin/bash
57-
58-stop jenkins-slave
59
60=== modified file 'metadata.yaml'
61--- metadata.yaml 2014-05-15 16:22:53 +0000
62+++ metadata.yaml 2015-09-23 15:10:40 +0000
63@@ -12,3 +12,7 @@
64 provides:
65 slave:
66 interface: jenkins-slave
67+ extension:
68+ interface: jenkins-extension
69+ scope: container
70+ optional: true

Subscribers

People subscribed via source and target branches