How to input json file as input parameter to jenkins job?

How to input json file as input parameter to jenkins job?

1 answer

  • answered 2018-04-14 15:45 Curious

    If you prefer to use Jenkins Pipeline, you can refer the following code:

    node {
        deleteDir()
        stage("upload") {
             def inputFile = input message: 'Upload file', parameters: [file(name: 'input.json')]
             new hudson.FilePath(new File("$workspace/input.json")).copyFrom(inputFile)
        inputFile.delete()
        }
       stage("checkout") {
             echo fileExists('input.json').toString()
             def props = readJSON file: '$workspace/input.json' // Read the json file
        }
        }
    

    Some Links to refer: