Last active
June 4, 2019 15:36
-
-
Save renizgo/8bcd531e94c2975fade81de1735d4706 to your computer and use it in GitHub Desktop.
Login on Kubernetes with credentials Jenkinsfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
def creds | |
stage('Sandbox') { | |
withCredentials([usernamePassword(credentialsId: 'my-creds', passwordVariable: 'C_PASS', usernameVariable: 'C_USER')]) { | |
creds = "\nUser: ${C_USER}\nPassword: ${C_PASS}\n" | |
} | |
println creds | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
node { | |
def creds | |
stage('Iniciando o Deploy') { | |
withCredentials([usernamePassword(credentialsId: 'admin_kube_dev', passwordVariable: 'C_PASS', usernameVariable: 'C_USER')]) { | |
creds = "${C_PASS}" | |
println creds | |
sh ''' | |
echo 'Inciando o deploy' | |
echo "Passowrd: ${C_PASS}" | |
kubectl config set-credentials k8s.dev.renato.io --username=admin --password=${C_PASS} | |
kubectl config set-cluster k8s.dev.renato.io --insecure-skip-tls-verify=true --server=https://api.k8s.dev.renato.io | |
kubectl config set-context k8s.dev.renato.io --user=k8s.dev.renato.io --namespace=default --cluster=k8s.dev.renato.io | |
kubectl config use-context k8s.dev.renato.io | |
kubectl get pods -n jenkins | |
''' | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment