java.lang.NoSuchMethodError:在步骤中找不到这样的 DSL 方法“withKubeConfig”[approveReceivedEvent,

问题描述 投票:0回答:2

我在 Jenkinsfile 中有以下代码,并安装了 kubernetes 插件。

steps {
    script {
        withKubeConfig([
            credentialsId: 'jenkins',
            caCertificate: '',
            serverUrl: '<URL>',
            contextName: '',
            clusterName: '',
            namespace: ''
        ]) {
            sh("kubectl get ns development || kubectl create ns development")
        }
    }
}

我收到以下错误

java.lang.NoSuchMethodError:在步骤中找不到这样的 DSL 方法“withKubeConfig”[approveReceivedEvent、approveRequestedEvent、archive、bat、build、catchError、checkout、container、containerLog、createEvent、deleteDir、dir、dockerFingerprintFrom、dockerFingerprintRun、echo、emailext、 emailextrecipients、envVarsForTool、错误、fileExists、findBuildScans、getContext、git、输入、isUnix、jiraComment、jiraIssueSelector、jiraSearch、junit、kubernetesApply、kubernetesDeploy、库、libraryResource、加载、锁定、邮件、里程碑、节点、并行、podTemplate、powershell、属性、publishChecks、publishHTML、pwd、pwsh、readFile、readTrusted、resolveScm、重试、脚本、setGitHubPullRequestStatus、sh、slackSend、slackUploadFile、slackUserIdFromEmail、slackUserIdsFromCommitters、睡眠、阶段、存储、步骤、svn、超时、时间戳、tm、工具、 unarchive、unstable、unstash、validateDeclarativePipeline、waitUntil、warnError、withContext、withCredentials、withDockerContainer、withDockerRegistry、withDockerServer、withEnv、withGradle、wrap、writeFile、ws] 或符号 [GenericTrigger、Number、Open、all、allBranchesSame、allOf、allowRunOnStatus、always 、ant、antFromApache、antOutcome、antPath、antTarget、any、anyOf、apiToken、架构、

有什么想法吗?请帮忙

jenkins jenkins-pipeline jenkins-plugins jenkins-groovy jenkins-job-dsl
2个回答
2
投票

此步骤是 kubernetes-cli-plugin 的一部分,而不是 kubernete-plugin 的一部分

https://github.com/jenkinsci/kubernetes-cli-plugin/blob/master/README.md


0
投票

安装 Kubernetes 插件后我遇到了同样的错误。它有效,所以我建议你去管理 Jenkins 并安装插件。

希望这有帮助

© www.soinside.com 2019 - 2024. All rights reserved.