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
=== modified file 'hooks/slave-relation-changed'
--- hooks/slave-relation-changed 2012-07-27 10:51:16 +0000
+++ hooks/slave-relation-changed 2015-09-23 15:10:40 +0000
@@ -1,6 +1,6 @@
1#!/bin/bash1#!/bin/bash
22
3set -e3set -eux
44
5# Setup connection to master instance once set5# Setup connection to master instance once set
6url=$(relation-get url)6url=$(relation-get url)
@@ -19,6 +19,18 @@
19 -e "s!^#*JENKINS_URL.*!JENKINS_URL=${url}!" \19 -e "s!^#*JENKINS_URL.*!JENKINS_URL=${url}!" \
20 /etc/default/jenkins-slave20 /etc/default/jenkins-slave
2121
22# Update JENKINS_ARGS so it can connect to the master and retrieve the agent
23# jnlp.
24username=$(relation-get username)
25password=$(relation-get password)
26credentials=""
27if [[ -n "${password}" && -n "${username}" ]]; then
28 juju-log "Configuring jenkins-slave credentials..."
29 credentials="-jnlpCredentials ${username}:${password}"
30fi
31
32sed -i -e "s!^JENKINS_ARGS.*!JENKINS_ARGS=\"-jnlpUrl \$JENKINS_URL/computer/\$JENKINS_HOSTNAME/slave-agent.jnlp ${credentials}\"!" /etc/default/jenkins-slave
33
22juju-log "Restarting jenkins-slave..."34juju-log "Restarting jenkins-slave..."
23# Startup the jenkins-slave service35# Startup the jenkins-slave service
24stop jenkins-slave 2>/dev/null || true36stop jenkins-slave 2>/dev/null || true
2537
=== modified file 'hooks/slave-relation-joined'
--- hooks/slave-relation-joined 2014-04-09 15:33:59 +0000
+++ hooks/slave-relation-joined 2015-09-23 15:10:40 +0000
@@ -1,6 +1,6 @@
1#!/bin/bash1#!/bin/bash
22
3set -e3set -eux
44
5# Set the slave hostname to match the juju unit5# Set the slave hostname to match the juju unit
6# in the jenkins master instance6# in the jenkins master instance
77
=== removed file 'hooks/start'
--- hooks/start 2011-08-02 08:53:54 +0000
+++ hooks/start 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1#!/bin/bash
2
3start jenkins-slave || true
40
=== removed file 'hooks/stop'
--- hooks/stop 2011-08-02 08:53:54 +0000
+++ hooks/stop 1970-01-01 00:00:00 +0000
@@ -1,3 +0,0 @@
1#!/bin/bash
2
3stop jenkins-slave
40
=== modified file 'metadata.yaml'
--- metadata.yaml 2014-05-15 16:22:53 +0000
+++ metadata.yaml 2015-09-23 15:10:40 +0000
@@ -12,3 +12,7 @@
12provides:12provides:
13 slave:13 slave:
14 interface: jenkins-slave14 interface: jenkins-slave
15 extension:
16 interface: jenkins-extension
17 scope: container
18 optional: true

Subscribers

People subscribed via source and target branches