jenkins 读取json文件_使用Jenkins写入工作区中的json文件

这篇博客介绍了如何在Jenkins作业中根据用户输入的参数更新工作区内的JSON文件。用户选择的环境参数和默认的文件名需要替换JSON文件中的相应值。作者尝试了Config File Provider Plugin但未能实现参数化,最终通过Groovy插件实现了该功能,读取构建参数并用Groovy脚本更新JSON文件。
摘要由CSDN通过智能技术生成

I've a jenkins job with few parameters setup and I've a JSON file in the workspace which has to be updated with the parameters that I pass through jenkins.

Example:

I have the following parameters which I'll take input from user who triggers the job:

Environment (Consider user selects "ENV2")

Filename (Consider user keeps the default value)

I have a json file in my workspace under run/job.json with the following contents:

{

environment: "ENV1",

filename: "abc.txt"

}

Now whatever the value is given by user before triggering a job has to be replaced in the job.json.

So when the user triggers the job, the job.json file should be:

{

environment: "ENV2",

filename: "abc.txt"

}

Please note the environment

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值