0

假设我在 Jenkins 中保存了一个 .properties 文件,看起来像

standardelectric_guest_plp
ladedanlar_employeelogin_checkout

我首先需要读取文件中的所有数据

接下来我需要使用文件的分隔符解析数据,比如

Websites=standardelectric,ladedanlar
User=guest,employeelogin
Page=plp,Checkout

有什么方法可以使用 shell 或任何其他我们可以在 Jenkins 本身中实现的方法来实现这一点。以上这些参数将输入到我的自动化脚本

4

2 回答 2

0

试试这个:

Websites="$(awk -F '_' '{print $1}' .properties | paste -d, -s)"
User="$(awk -F '_' '{print $2}' .properties | paste -d, -s)"
Page="$(awk -F '_' '{print $3}' .properties | paste -d, -s)"
于 2020-03-20T08:34:11.690 回答
0

我会为此使用ConvertFrom-Csvcmdlet:

$File = @'
standardelectric_guest_plp
ladedanlar_employeelogin_checkout
'@

$Data = $File | ConvertFrom-Csv -Delimiter _ -Header Websites,User,Page

抓住你的财产:

$Data.User                         #PowerSehll v3+
$Data | Select-Object -Expand User #PowerShell v2
于 2020-03-20T12:36:08.633 回答