I'm trying to use Jenkins Kubernetes CLI plugin from https://plugins.jenkins.io/kubernetes-cli/ to let deploy artifacts from Jenkins to GKE cluster.

Expected Behavior

Get cluster info on kubectl cluster-info

Actual Behavior

Error out as Unable to connect to the server: x509: certificate signed by unknown authority

Steps to Reproduce the Problem

Output of generated ./kube/config

+ kubectl config view
apiVersion: v1
- cluster:
    certificate-authority-data: DATA+OMITTED
    server: https://xxx.xxx.xxx.yyy
  name: my-cluster
- context:
    cluster: my-cluster
    user: jenkins-pipeline
  name: my-cluster-jenkins
current-context: my-cluster-jenkins
kind: Config
preferences: {}
- name: jenkins-pipeline
    username: jenkins-pipelin

When I run from a command line I need to do


Where that part goes in that plugin?

2 Answers 2


Put it inside the sh?

withKubeConfig(...) {
  sh “””
    export ...
    kubectl ...
  • That will not work as by default plugin is working with user access with token not the key.json Commented Feb 24, 2021 at 18:34
  • So when you run from command line with the export, subsequent kubectl (per plugin page) reads the contents of the file?
    – Chris F
    Commented Feb 24, 2021 at 19:05
  • From the plugin page, you want to somehow use the contents of your key.json file for credentialsId?
    – Chris F
    Commented Feb 24, 2021 at 19:11

Whatever machine you're running kubectl on is reading a kube config (likely ~/.kube/config) with a client-certificate-data or client-key-data that doesn't correspond to the server you're communicating with.

You likely want to remove ~/.kube/config and use the one you download from Google.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.