1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/bin/bash -xev
juju-log "Updating extension interface with up-to-date data..."
JENKINS_URL=$(relation-get jenkins_url)
JENKINS_USERNAME=$(relation-get admin_username)
JENKINS_PASSWORD=$(relation-get admin_password)
if [[ -z ${JENKINS_URL} ]] ||
[[ -z ${JENKINS_USERNAME} ]] ||
[[ -z ${JENKINS_PASSWORD} ]]; then
juju-log "Requested relation data not sent back yet..."
exit 0
fi
JOB_PATH="$(pwd)/files/bygmester/jobs/"
KEY_PATH="$(pwd)/files/keys/"
if [[ -d ${JOB_PATH} && -d ${KEY_PATH} ]]; then
juju-log "Creating the JenkinsServer object..."
sudo capomastro import_jenkinsserver --update "jenkins server" "${JENKINS_URL}" "${JENKINS_USERNAME}" "${JENKINS_PASSWORD}"
# Create all JobTypes for each component
pushd ${JOB_PATH}
for JOB_CONFIG in $(find . -name "jenkins.xml" -exec readlink -f {} \;); do
JOB_TYPE=$(basename $(dirname $JOB_CONFIG))
juju-log "Importing JobType ${JOB_TYPE} into Capomastro..."
sudo capomastro import_jobtype --update "${JOB_TYPE}" "${JOB_CONFIG}"
done
popd
# Create Credentials
PRIVATE_KEY="${KEY_PATH}/capomastro"
PUBLIC_KEY="${KEY_PATH}/capomastro.pub"
juju-log "Importing the service key pair into the Jenkins server..."
sudo capomastro import_sshkeypair --update "${PUBLIC_KEY}" "${PRIVATE_KEY}" "capomastro"
fi
|