java.lang.NoSuchMethodError: No such DSL method 'readJSON'

26,810

Solution 1

Using Pipeline Utility Steps Plugin you can use the readJSON function.

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

You can not use this function without this plugin.

For more info check: Steps

Solution 2

Install the Pipeline Utility Steps plugin.

Solution 3

And in my case it was just a stupid typo: readJson instead of readJSON.

Share:
26,810
bigskull
Author by

bigskull

Updated on May 25, 2020

Comments

  • bigskull
    bigskull almost 4 years
    def data = readJSON text: '{"rel" : {"configVersion": "1.0","manifest" :"'+"${manifestURL}"+'"}}'
    writeJSON(file: 'C:\\Users\\Public\\json\\config.json', json: data)
    

    I am using JSON function in my Jenkins pipeline and getting NoSuchMethodFoundError. I am using Jenkins 2.85.

    Any idea how to resolve this issue?

    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,