Bootstrap

jenkins 读取json文件_如何将json文件作为输入参数输入到jenkins作业?

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

解决方案

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:

If you dont want to use a Jenkins pipeline job refer this link

;