web-dev-qa-db-ja.com

java.lang.NoSuchMethodError:そのようなDSLメソッド「readJSON」はありません

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, 
12
Srinivas

Pipeline Utility Steps Plugin を使用すると、readJSON関数を使用できます。

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

このプラグインなしでは、この機能は使用できません。

詳細情報の確認: Steps

13
Javier C.

Pipeline Utility Stepsプラグイン。

7
Rob Hales

そして、私の場合、それはただの愚かなタイプミスでした:readJSONではなくreadJson。

0
BartBiczBoży