Reputation: 77
I have following code in Jenkinsfile , and have installed kubernetes plugin installed.
steps {
script {
withKubeConfig([
credentialsId: 'jenkins',
caCertificate: '',
serverUrl: '<URL>',
contextName: '',
clusterName: '',
namespace: ''
]) {
sh("kubectl get ns development || kubectl create ns development")
}
}
}
I am getting the following error
java.lang.NoSuchMethodError: No such DSL method 'withKubeConfig' found among steps [approveReceivedEvent, approveRequestedEvent, archive, bat, build, catchError, checkout, container, containerLog, createEvent, deleteDir, dir, dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, emailextrecipients, envVarsForTool, error, fileExists, findBuildScans, getContext, git, input, isUnix, jiraComment, jiraIssueSelector, jiraSearch, junit, kubernetesApply, kubernetesDeploy, library, libraryResource, load, lock, mail, milestone, node, parallel, podTemplate, powershell, properties, publishChecks, publishHTML, pwd, pwsh, readFile, readTrusted, resolveScm, retry, script, setGitHubPullRequestStatus, sh, slackSend, slackUploadFile, slackUserIdFromEmail, slackUserIdsFromCommitters, sleep, stage, stash, step, svn, timeout, timestamps, tm, tool, unarchive, unstable, unstash, validateDeclarativePipeline, waitUntil, warnError, withContext, withCredentials, withDockerContainer, withDockerRegistry, withDockerServer, withEnv, withGradle, wrap, writeFile, ws] or symbols [GenericTrigger, Number, Open, all, allBranchesSame, allOf, allowRunOnStatus, always, ant, antFromApache, antOutcome, antPath, antTarget, any, anyOf, apiToken, architecture,
Any Idea? Please help
Upvotes: 1
Views: 4237
Reputation: 1
I had the same error after installing the Kubernetes plugin. It worked so I suggest you go to manage Jenkins and install the plugin.
Hope this helps
Upvotes: 0
Reputation: 1962
This step is part of the kubernetes-cli-plugin rather than the kubernete-plugin
https://github.com/jenkinsci/kubernetes-cli-plugin/blob/master/README.md
Upvotes: 2