adds logic to install curl/kubectl only if it does not already exist fro multiple calls and adds create secret
This commit is contained in:
@@ -54,9 +54,13 @@ def deletePod (Map config) {
|
||||
stage ("Delete Pod") {
|
||||
container ("alpine") {
|
||||
sh """
|
||||
apk add --no-cache curl
|
||||
curl -L --silent https://nexus.c.test-chamber-13.lan/repository/google-k8s/\$(curl -s https://nexus.c.test-chamber-13.lan/repository/google-k8s/stable.txt)/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
|
||||
chmod +x /usr/local/bin/kubectl
|
||||
if [ ! -f "/usr/bin/curl" ] || [ ! -x "/usr/bin/curl" ]; then
|
||||
apk add --no-cache curl
|
||||
fi
|
||||
if [ ! -f "/usr/local/bin/kubectl" ] || [ ! -x "/usr/local/bin/kubectl" ]; then
|
||||
curl -L --silent https://nexus.c.test-chamber-13.lan/repository/google-k8s/\$(curl -s https://nexus.c.test-chamber-13.lan/repository/google-k8s/stable.txt)/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
|
||||
chmod +x /usr/local/bin/kubectl
|
||||
fi
|
||||
"""
|
||||
|
||||
withKubeConfig ([
|
||||
@@ -70,6 +74,31 @@ def deletePod (Map config) {
|
||||
}
|
||||
}
|
||||
|
||||
def createSecret (Map config) {
|
||||
def ws = pwd()
|
||||
stage ("Create Secret") {
|
||||
container ("alpine") {
|
||||
sh """
|
||||
if [ ! -f "/usr/bin/curl" ] || [ ! -x "/usr/bin/curl" ]; then
|
||||
apk add --no-cache curl
|
||||
fi
|
||||
if [ ! -f "/usr/local/bin/kubectl" ] || [ ! -x "/usr/local/bin/kubectl" ]; then
|
||||
curl -L --silent https://nexus.c.test-chamber-13.lan/repository/google-k8s/\$(curl -s https://nexus.c.test-chamber-13.lan/repository/google-k8s/stable.txt)/bin/linux/amd64/kubectl -o /usr/local/bin/kubectl
|
||||
chmod +x /usr/local/bin/kubectl
|
||||
fi
|
||||
"""
|
||||
|
||||
withKubeConfig ([
|
||||
credentialsId: config.kubeAuth,
|
||||
serverUrl: config.kubeURL,
|
||||
namespace: config.namespace
|
||||
]) {
|
||||
sh "printf '%s\n' \"" + config.secret + "\" | kubectl apply -f -"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def buildContainer (Map config, List buildArg = []) {
|
||||
def ws = pwd()
|
||||
stage ("Build Container") {
|
||||
|
Reference in New Issue
Block a user