如何将json文件作为输入参数输入给jenkins作业? [英] How to input json file as input parameter to jenkins job?
本文介绍了如何将json文件作为输入参数输入给jenkins作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何输入json文件作为 jenkins 作业的输入参数?
How to input json file as input parameter to jenkins job?
推荐答案
如果您更喜欢使用Jenkins Pipeline,则可以引用以下代码:
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
}
}
一些链接引用:
- Similar Question
- Reading a json file
- If you dont want to use a Jenkins pipeline job refer this link
这篇关于如何将json文件作为输入参数输入给jenkins作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文