【问题标题】:java.lang.NoSuchMethodError: No such DSL method 'readJSON'java.lang.NoSuchMethodError:没有这样的 DSL 方法“readJSON”
【发布时间】:2017-10-20 03:12:43
【问题描述】:
def data = readJSON text: '{"rel" : {"configVersion": "1.0","manifest" :"'+"${manifestURL}"+'"}}'
writeJSON(file: 'C:\\Users\\Public\\json\\config.json', json: data)

我在我的 Jenkins 管道中使用 JSON 函数并获得 NoSuchMethodFoundError。我正在使用 Jenkins 2.85。

知道如何解决这个问题吗?

java.lang.NoSuchMethodError: No such DSL method 'readJSON' found among steps 
[archive, bat, build, catchError, checkout, deleteDir, dir, 
dockerFingerprintFrom, dockerFingerprintRun, echo, emailext, 
emailextrecipients, envVarsForTool, error, fileExists, getContext, git, 
input, isUnix, library, libraryResource, load, mail, milestone, node, 
parallel, powershell, properties, pwd, readFile, readTrusted, resolveScm, 
retry, script, sh, sleep, stage, stash, step, svn, timeout, timestamps, tm, 
tool, unarchive, unstash, validateDeclarativePipeline, waitUntil, 
withContext, withCredentials, withDockerContainer, withDockerRegistry, 
withDockerServer, withEnv, wrap, writeFile, ws] or symbols [all, allOf, 
always, ant, antFromApache, antOutcome, antTarget, any, anyOf, apiToken, 
architecture, archiveArtifacts, artifactManager, authorizationMatrix, 
batchFile, booleanParam, branch, buildButton, buildDiscarder, 
caseInsensitive, caseSensitive, certificate, changelog, changeset, choice, 
choiceParam, cleanWs, clock, cloud, command, credentials, cron, crumb, 
defaultView, demand, disableConcurrentBuilds, docker, dockerCert, 
dockerfile, downloadSettings, downstream, dumb, envVars, environment, 
expression, file, fileParam, filePath, fingerprint, frameOptions, freeStyle, 
freeStyleJob, fromScm, fromSource, git, github, githubPush, gradle, 
headRegexFilter, headWildcardFilter, hyperlink, hyperlinkToModels, 
inheriting, inheritingGlobal, installSource, jdk, jdkInstaller, jgit, 
jgitapache, jnlp, jobName, junit, label, lastDuration, lastFailure, 
lastGrantedAuthorities, lastStable, lastSuccess, legacy, legacySCM, list, 
local, location, logRotator, loggedInUsersCanDoAnything, masterBuild, maven, 
maven3Mojos, mavenErrors, mavenMojos, mavenWarnings, modernSCM, myView, 
node, nodeProperties, nonInheriting, 

【问题讨论】:

    标签: json jenkins groovy continuous-integration jenkins-pipeline


    【解决方案1】:

    使用Pipeline Utility Steps Plugin,您可以使用readJSON 函数。

    def props = readJSON text: '{ "key": "value" }'
    

    没有这个插件你不能使用这个功能。

    更多信息请查看:Steps

    【讨论】:

      【解决方案2】:

      安装Pipeline Utility Steps 插件。

      【讨论】:

        【解决方案3】:

        在我的例子中,这只是一个愚蠢的错字:readJson 而不是 readJSON。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2019-01-11
          • 1970-01-01
          • 1970-01-01
          • 2020-04-30
          • 2018-05-13
          • 1970-01-01
          • 2018-09-17
          • 1970-01-01
          相关资源
          最近更新 更多