-
Notifications
You must be signed in to change notification settings - Fork 1
/
copy-jenkins-config.sh
executable file
·17 lines (12 loc) · 1.03 KB
/
copy-jenkins-config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash
JENKINS_MASTER=$(kubectl get pods -n jenkins --selector=component=jenkins-jenkins-master -o json | jq -r '.items[0].metadata.name')
# Go to jenkins dashboard and create pipeline
kubectl cp jenkins/$JENKINS_MASTER:/var/jenkins_home/secrets/hudson.util.Secret jenkins-secrets/
kubectl cp jenkins/$JENKINS_MASTER:/var/jenkins_home/secrets/master.key jenkins-secrets/
kubectl cp jenkins/$JENKINS_MASTER:/var/jenkins_home/users/admin/config.xml jenkins-secrets/
kubectl cp jenkins/$JENKINS_MASTER:/var/jenkins_home/credentials.xml jenkins-secrets/
kubectl cp jenkins/$JENKINS_MASTER:/var/jenkins_home/jobs/ jenkins-jobs/
# Create secrets to allow for decrypting stored configuration in the future (e.g. the Github API token)
kubectl create secret generic jenkins-secrets --namespace jenkins --from-file=jenkins-secrets/master.key --from-file=jenkins-secrets/hudson.util.Secret
# Create jenkins secret for storing credentials
kubectl create secret generic jenkins-credentials --namespace jenkins --from-file=jenkins-secrets/credentials.xml