如何将json文件作为输入参数输入 jenkins 作业?
答案 0 :(得分:2)
如果您更喜欢使用Jenkins Pipeline,可以参考以下代码:
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
}
}
要参考的一些链接: