简体   繁体   English

如何使用Jenkins参数向属性文件添加值

[英]How to add a value to property file using Jenkins parameter

I have testdata.properties file where I have many key values pairs as below 我有testdata.properties文件,其中有许多键值对,如下所示

user=dinesh
password=dinesh123
phone=1234

Am using testdata.properties file to pass the input parameters to run the automation script. 我正在使用testdata.properties文件传递输入参数以运行自动化脚本。

Example: When I run my jenkins jobs with build parameter for example am entering phone number as 567 it should replace the value in the testdata.properties 示例:例如,当我使用build参数运行jenkins作业时,例如输入电话号码为567,它应该替换testdata.properties中的值

phone=567

Is it possible to set the above parameters from Jenkins job by passing the build as String parameter or something ? 是否可以通过将build作为String参数传递给Jenkins作业来设置上述参数?

In your build environment, you can include a shell action and echo your Jenkins parameter to the properties file. 在您的构建环境中,您可以包括一个shell操作,并将您的Jenkins参数回显到属性文件。

eg, 例如,

#!/bin/bash

echo phone=$PHONE_REPLACE_SEQ >> /path/to/testdata.properties

您可以使用writeFile步骤,但是它将重写整个文件,而不仅仅是替换单个值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM